mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
Add ability to link to v8_libbase.
This commit is contained in:
parent
168cc755cf
commit
ec65717c59
3 changed files with 25 additions and 17 deletions
|
@ -11,6 +11,7 @@ executable("deno") {
|
|||
":msg_proto",
|
||||
"//third_party/protobuf:protoc_lib",
|
||||
]
|
||||
public_configs = [ ":public_v8_base_config" ]
|
||||
}
|
||||
|
||||
executable("mock_runtime_test") {
|
||||
|
@ -52,6 +53,15 @@ source_set("deno_nosnapshot") {
|
|||
"v8:v8_libplatform",
|
||||
"v8:v8_libsampler",
|
||||
]
|
||||
public_configs = [ ":public_v8_base_config" ]
|
||||
}
|
||||
|
||||
# This allows us to v8/src/base/ libraries.
|
||||
config("public_v8_base_config") {
|
||||
include_dirs = [
|
||||
"v8",
|
||||
"$target_gen_dir/v8",
|
||||
]
|
||||
}
|
||||
|
||||
executable("snapshot_creator") {
|
||||
|
|
|
@ -19,20 +19,18 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "v8/src/base/logging.h"
|
||||
#include "v8/include/libplatform/libplatform.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
||||
#include "./deno_internal.h"
|
||||
#include "include/deno.h"
|
||||
|
||||
#define CHECK(x) assert(x) // TODO(ry) use V8's CHECK.
|
||||
|
||||
namespace deno {
|
||||
|
||||
// Extracts a C string from a v8::V8 Utf8Value.
|
||||
|
@ -92,7 +90,7 @@ void ExitOnPromiseRejectCallback(
|
|||
v8::PromiseRejectMessage promise_reject_message) {
|
||||
auto* isolate = v8::Isolate::GetCurrent();
|
||||
Deno* d = static_cast<Deno*>(isolate->GetData(0));
|
||||
assert(d->isolate == isolate);
|
||||
DCHECK_EQ(d->isolate, isolate);
|
||||
v8::HandleScope handle_scope(d->isolate);
|
||||
auto exception = promise_reject_message.GetValue();
|
||||
auto context = d->context.Get(d->isolate);
|
||||
|
@ -100,7 +98,7 @@ void ExitOnPromiseRejectCallback(
|
|||
}
|
||||
|
||||
void Print(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
assert(args.Length() == 1);
|
||||
CHECK_EQ(args.Length(), 1);
|
||||
auto* isolate = args.GetIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::String::Utf8Value str(isolate, args[0]);
|
||||
|
@ -113,7 +111,7 @@ void Print(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|||
void Sub(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
Deno* d = reinterpret_cast<Deno*>(isolate->GetData(0));
|
||||
assert(d->isolate == isolate);
|
||||
DCHECK_EQ(d->isolate, isolate);
|
||||
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
|
@ -123,7 +121,7 @@ void Sub(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|||
}
|
||||
|
||||
v8::Local<v8::Value> v = args[0];
|
||||
assert(v->IsFunction());
|
||||
CHECK(v->IsFunction());
|
||||
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(v);
|
||||
|
||||
d->sub.Reset(isolate, func);
|
||||
|
@ -132,19 +130,19 @@ void Sub(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|||
void Pub(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
Deno* d = static_cast<Deno*>(isolate->GetData(0));
|
||||
assert(d->isolate == isolate);
|
||||
DCHECK_EQ(d->isolate, isolate);
|
||||
|
||||
v8::Locker locker(d->isolate);
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
|
||||
assert(args.Length() == 2);
|
||||
CHECK_EQ(args.Length(), 2);
|
||||
v8::Local<v8::Value> channel_v = args[0];
|
||||
assert(channel_v->IsString());
|
||||
CHECK(channel_v->IsString());
|
||||
v8::String::Utf8Value channel_vstr(isolate, channel_v);
|
||||
const char* channel = *channel_vstr;
|
||||
|
||||
v8::Local<v8::Value> ab_v = args[1];
|
||||
assert(ab_v->IsArrayBuffer());
|
||||
CHECK(ab_v->IsArrayBuffer());
|
||||
|
||||
auto ab = v8::Local<v8::ArrayBuffer>::Cast(ab_v);
|
||||
auto contents = ab->GetContents();
|
||||
|
@ -154,7 +152,7 @@ void Pub(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
|||
const_cast<const char*>(reinterpret_cast<char*>(contents.Data()));
|
||||
deno_buf buf{data, contents.ByteLength()};
|
||||
|
||||
assert(d->currentArgs == nullptr);
|
||||
DCHECK_EQ(d->currentArgs, nullptr);
|
||||
d->currentArgs = &args;
|
||||
|
||||
d->cb(d, channel, buf);
|
||||
|
@ -180,7 +178,7 @@ bool Execute(v8::Local<v8::Context> context, const char* js_filename,
|
|||
auto script = v8::Script::Compile(context, source, &origin);
|
||||
|
||||
if (script.IsEmpty()) {
|
||||
assert(try_catch.HasCaught());
|
||||
DCHECK(try_catch.HasCaught());
|
||||
HandleException(context, try_catch.Exception());
|
||||
return false;
|
||||
}
|
||||
|
@ -188,7 +186,7 @@ bool Execute(v8::Local<v8::Context> context, const char* js_filename,
|
|||
auto result = script.ToLocalChecked()->Run(context);
|
||||
|
||||
if (result.IsEmpty()) {
|
||||
assert(try_catch.HasCaught());
|
||||
DCHECK(try_catch.HasCaught());
|
||||
HandleException(context, try_catch.Exception());
|
||||
return false;
|
||||
}
|
||||
|
@ -198,7 +196,7 @@ bool Execute(v8::Local<v8::Context> context, const char* js_filename,
|
|||
|
||||
v8::StartupData SerializeInternalFields(v8::Local<v8::Object> holder, int index,
|
||||
void* data) {
|
||||
assert(data == nullptr); // TODO(ry) pass Deno* object here.
|
||||
DCHECK_EQ(data, nullptr); // TODO(ry) pass Deno* object here.
|
||||
InternalFieldData* embedder_field = static_cast<InternalFieldData*>(
|
||||
holder->GetAlignedPointerFromInternalField(index));
|
||||
if (embedder_field == nullptr) return {nullptr, 0};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2018 Ryan Dahl <ry@tinyclouds.org>
|
||||
// All rights reserved. MIT License.
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
|
||||
#include "v8/src/base/logging.h"
|
||||
#include "./msg.pb.h"
|
||||
#include "include/deno.h"
|
||||
|
||||
|
@ -20,7 +20,7 @@ void MessagesFromJS(Deno* d, const char* channel, deno_buf buf) {
|
|||
response.set_start_cwd(cwd);
|
||||
|
||||
std::string output;
|
||||
assert(response.SerializeToString(&output) == true);
|
||||
CHECK(response.SerializeToString(&output));
|
||||
|
||||
auto bufout = deno_buf{output.c_str(), output.length()};
|
||||
deno_set_response(d, bufout);
|
||||
|
|
Loading…
Reference in a new issue