| Index: src/d8.cc
|
| diff --git a/src/d8.cc b/src/d8.cc
|
| index d3bfcbcc078b67bf7b8627b5879e54569b219bef..344325e1b90c284112d90401ccf229a04a789625 100644
|
| --- a/src/d8.cc
|
| +++ b/src/d8.cc
|
| @@ -108,7 +108,7 @@
|
|
|
|
|
| #ifndef V8_SHARED
|
| -bool FindInObjectList(Local<Object> object, const Shell::ObjectList& list) {
|
| +bool FindInObjectList(Handle<Object> object, const Shell::ObjectList& list) {
|
| for (int i = 0; i < list.length(); ++i) {
|
| if (list[i]->StrictEquals(object)) {
|
| return true;
|
| @@ -122,10 +122,8 @@
|
| } // namespace
|
|
|
|
|
| -static Local<Value> Throw(Isolate* isolate, const char* message) {
|
| - return isolate->ThrowException(
|
| - String::NewFromUtf8(isolate, message, NewStringType::kNormal)
|
| - .ToLocalChecked());
|
| +static Handle<Value> Throw(Isolate* isolate, const char* message) {
|
| + return isolate->ThrowException(String::NewFromUtf8(isolate, message));
|
| }
|
|
|
|
|
| @@ -160,12 +158,12 @@
|
| int realm_count_;
|
| int realm_current_;
|
| int realm_switch_;
|
| - Global<Context>* realms_;
|
| - Global<Value> realm_shared_;
|
| + Persistent<Context>* realms_;
|
| + Persistent<Value> realm_shared_;
|
|
|
| int RealmIndexOrThrow(const v8::FunctionCallbackInfo<v8::Value>& args,
|
| int arg_offset);
|
| - int RealmFind(Local<Context> context);
|
| + int RealmFind(Handle<Context> context);
|
| };
|
|
|
|
|
| @@ -182,14 +180,13 @@
|
| public:
|
| explicit DumbLineEditor(Isolate* isolate)
|
| : LineEditor(LineEditor::DUMB, "dumb"), isolate_(isolate) { }
|
| - virtual Local<String> Prompt(const char* prompt);
|
| -
|
| + virtual Handle<String> Prompt(const char* prompt);
|
| private:
|
| Isolate* isolate_;
|
| };
|
|
|
|
|
| -Local<String> DumbLineEditor::Prompt(const char* prompt) {
|
| +Handle<String> DumbLineEditor::Prompt(const char* prompt) {
|
| printf("%s", prompt);
|
| #if defined(__native_client__)
|
| // Native Client libc is used to being embedded in Chrome and
|
| @@ -208,14 +205,14 @@
|
| base::LazyMutex Shell::context_mutex_;
|
| const base::TimeTicks Shell::kInitialTicks =
|
| base::TimeTicks::HighResolutionNow();
|
| -Global<Context> Shell::utility_context_;
|
| +Persistent<Context> Shell::utility_context_;
|
| base::LazyMutex Shell::workers_mutex_;
|
| bool Shell::allow_new_workers_ = true;
|
| i::List<Worker*> Shell::workers_;
|
| i::List<SharedArrayBuffer::Contents> Shell::externalized_shared_contents_;
|
| #endif // !V8_SHARED
|
|
|
| -Global<Context> Shell::evaluation_context_;
|
| +Persistent<Context> Shell::evaluation_context_;
|
| ArrayBuffer::Allocator* Shell::array_buffer_allocator;
|
| ShellOptions Shell::options;
|
| const char* Shell::kPrompt = "d8> ";
|
| @@ -258,21 +255,18 @@
|
| Isolate::Scope isolate_scope(temp_isolate);
|
| HandleScope handle_scope(temp_isolate);
|
| Context::Scope context_scope(Context::New(temp_isolate));
|
| - Local<String> source_copy =
|
| - v8::String::NewFromTwoByte(temp_isolate, source_buffer,
|
| - v8::NewStringType::kNormal,
|
| - source_length).ToLocalChecked();
|
| + Local<String> source_copy = v8::String::NewFromTwoByte(
|
| + temp_isolate, source_buffer, v8::String::kNormalString, source_length);
|
| Local<Value> name_copy;
|
| if (name_buffer) {
|
| - name_copy = v8::String::NewFromTwoByte(temp_isolate, name_buffer,
|
| - v8::NewStringType::kNormal,
|
| - name_length).ToLocalChecked();
|
| + name_copy = v8::String::NewFromTwoByte(
|
| + temp_isolate, name_buffer, v8::String::kNormalString, name_length);
|
| } else {
|
| name_copy = v8::Undefined(temp_isolate);
|
| }
|
| ScriptCompiler::Source script_source(source_copy, ScriptOrigin(name_copy));
|
| - ScriptCompiler::CompileUnboundScript(temp_isolate, &script_source,
|
| - compile_options).ToLocalChecked();
|
| + ScriptCompiler::CompileUnbound(temp_isolate, &script_source,
|
| + compile_options);
|
| if (script_source.GetCachedData()) {
|
| int length = script_source.GetCachedData()->length;
|
| uint8_t* cache = new uint8_t[length];
|
| @@ -289,17 +283,16 @@
|
|
|
|
|
| // Compile a string within the current v8 context.
|
| -MaybeLocal<Script> Shell::CompileString(
|
| +Local<Script> Shell::CompileString(
|
| Isolate* isolate, Local<String> source, Local<Value> name,
|
| ScriptCompiler::CompileOptions compile_options, SourceType source_type) {
|
| - Local<Context> context(isolate->GetCurrentContext());
|
| ScriptOrigin origin(name);
|
| if (compile_options == ScriptCompiler::kNoCompileOptions) {
|
| ScriptCompiler::Source script_source(source, origin);
|
| return source_type == SCRIPT
|
| - ? ScriptCompiler::Compile(context, &script_source,
|
| + ? ScriptCompiler::Compile(isolate, &script_source,
|
| compile_options)
|
| - : ScriptCompiler::CompileModule(context, &script_source,
|
| + : ScriptCompiler::CompileModule(isolate, &script_source,
|
| compile_options);
|
| }
|
|
|
| @@ -314,10 +307,10 @@
|
| DCHECK(false); // A new compile option?
|
| }
|
| if (data == NULL) compile_options = ScriptCompiler::kNoCompileOptions;
|
| - MaybeLocal<Script> result =
|
| + Local<Script> result =
|
| source_type == SCRIPT
|
| - ? ScriptCompiler::Compile(context, &cached_source, compile_options)
|
| - : ScriptCompiler::CompileModule(context, &cached_source,
|
| + ? ScriptCompiler::Compile(isolate, &cached_source, compile_options)
|
| + : ScriptCompiler::CompileModule(isolate, &cached_source,
|
| compile_options);
|
| CHECK(data == NULL || !data->rejected);
|
| return result;
|
| @@ -325,8 +318,8 @@
|
|
|
|
|
| // Executes a string within the current v8 context.
|
| -bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
|
| - Local<Value> name, bool print_result,
|
| +bool Shell::ExecuteString(Isolate* isolate, Handle<String> source,
|
| + Handle<Value> name, bool print_result,
|
| bool report_exceptions, SourceType source_type) {
|
| #ifndef V8_SHARED
|
| bool FLAG_debugger = i::FLAG_debugger;
|
| @@ -341,26 +334,25 @@
|
| try_catch.SetVerbose(true);
|
| }
|
|
|
| - MaybeLocal<Value> maybe_result;
|
| + Handle<Value> result;
|
| {
|
| PerIsolateData* data = PerIsolateData::Get(isolate);
|
| Local<Context> realm =
|
| Local<Context>::New(isolate, data->realms_[data->realm_current_]);
|
| Context::Scope context_scope(realm);
|
| - Local<Script> script;
|
| - if (!Shell::CompileString(isolate, source, name, options.compile_options,
|
| - source_type).ToLocal(&script)) {
|
| + Handle<Script> script = Shell::CompileString(
|
| + isolate, source, name, options.compile_options, source_type);
|
| + if (script.IsEmpty()) {
|
| // Print errors that happened during compilation.
|
| if (report_exceptions && !FLAG_debugger)
|
| ReportException(isolate, &try_catch);
|
| return false;
|
| }
|
| - maybe_result = script->Run(realm);
|
| + result = script->Run();
|
| EmptyMessageQueues(isolate);
|
| data->realm_current_ = data->realm_switch_;
|
| }
|
| - Local<Value> result;
|
| - if (!maybe_result.ToLocal(&result)) {
|
| + if (result.IsEmpty()) {
|
| DCHECK(try_catch.HasCaught());
|
| // Print errors that happened during execution.
|
| if (report_exceptions && !FLAG_debugger)
|
| @@ -385,19 +377,12 @@
|
| v8::Local<v8::Context> context =
|
| v8::Local<v8::Context>::New(isolate, utility_context_);
|
| v8::Context::Scope context_scope(context);
|
| - Local<Object> global = context->Global();
|
| - Local<Value> fun =
|
| - global->Get(context, String::NewFromUtf8(isolate, "Stringify",
|
| - v8::NewStringType::kNormal)
|
| - .ToLocalChecked()).ToLocalChecked();
|
| - Local<Value> argv[1] = {result};
|
| - Local<Value> s;
|
| - if (!Local<Function>::Cast(fun)
|
| - ->Call(context, global, 1, argv)
|
| - .ToLocal(&s)) {
|
| - return true;
|
| - }
|
| - DCHECK(!try_catch.HasCaught());
|
| + Handle<Object> global = context->Global();
|
| + Handle<Value> fun =
|
| + global->Get(String::NewFromUtf8(isolate, "Stringify"));
|
| + Handle<Value> argv[1] = {result};
|
| + Handle<Value> s = Handle<Function>::Cast(fun)->Call(global, 1, argv);
|
| + if (try_catch.HasCaught()) return true;
|
| v8::String::Utf8Value str(s);
|
| fwrite(*str, sizeof(**str), str.length(), stdout);
|
| printf("\n");
|
| @@ -412,7 +397,7 @@
|
| data_->realm_count_ = 1;
|
| data_->realm_current_ = 0;
|
| data_->realm_switch_ = 0;
|
| - data_->realms_ = new Global<Context>[1];
|
| + data_->realms_ = new Persistent<Context>[1];
|
| data_->realms_[0].Reset(data_->isolate_,
|
| data_->isolate_->GetEnteredContext());
|
| }
|
| @@ -428,7 +413,7 @@
|
| }
|
|
|
|
|
| -int PerIsolateData::RealmFind(Local<Context> context) {
|
| +int PerIsolateData::RealmFind(Handle<Context> context) {
|
| for (int i = 0; i < realm_count_; ++i) {
|
| if (realms_[i] == context) return i;
|
| }
|
| @@ -443,10 +428,10 @@
|
| Throw(args.GetIsolate(), "Invalid argument");
|
| return -1;
|
| }
|
| - int index = args[arg_offset]
|
| - ->Int32Value(args.GetIsolate()->GetCurrentContext())
|
| - .FromMaybe(-1);
|
| - if (index < 0 || index >= realm_count_ || realms_[index].IsEmpty()) {
|
| + int index = args[arg_offset]->Int32Value();
|
| + if (index < 0 ||
|
| + index >= realm_count_ ||
|
| + realms_[index].IsEmpty()) {
|
| Throw(args.GetIsolate(), "Invalid realm index");
|
| return -1;
|
| }
|
| @@ -490,10 +475,7 @@
|
| Throw(args.GetIsolate(), "Invalid argument");
|
| return;
|
| }
|
| - int index = data->RealmFind(args[0]
|
| - ->ToObject(isolate->GetCurrentContext())
|
| - .ToLocalChecked()
|
| - ->CreationContext());
|
| + int index = data->RealmFind(args[0]->ToObject(isolate)->CreationContext());
|
| if (index == -1) return;
|
| args.GetReturnValue().Set(index);
|
| }
|
| @@ -515,15 +497,15 @@
|
| Isolate* isolate = args.GetIsolate();
|
| TryCatch try_catch(isolate);
|
| PerIsolateData* data = PerIsolateData::Get(isolate);
|
| - Global<Context>* old_realms = data->realms_;
|
| + Persistent<Context>* old_realms = data->realms_;
|
| int index = data->realm_count_;
|
| - data->realms_ = new Global<Context>[++data->realm_count_];
|
| + data->realms_ = new Persistent<Context>[++data->realm_count_];
|
| for (int i = 0; i < index; ++i) {
|
| data->realms_[i].Reset(isolate, old_realms[i]);
|
| old_realms[i].Reset();
|
| }
|
| delete[] old_realms;
|
| - Local<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
|
| + Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
|
| Local<Context> context = Context::New(isolate, NULL, global_template);
|
| if (context.IsEmpty()) {
|
| DCHECK(try_catch.HasCaught());
|
| @@ -572,20 +554,13 @@
|
| Throw(args.GetIsolate(), "Invalid argument");
|
| return;
|
| }
|
| - ScriptCompiler::Source script_source(
|
| - args[1]->ToString(isolate->GetCurrentContext()).ToLocalChecked());
|
| - Local<UnboundScript> script;
|
| - if (!ScriptCompiler::CompileUnboundScript(isolate, &script_source)
|
| - .ToLocal(&script)) {
|
| - return;
|
| - }
|
| + ScriptCompiler::Source script_source(args[1]->ToString(isolate));
|
| + Handle<UnboundScript> script = ScriptCompiler::CompileUnbound(
|
| + isolate, &script_source);
|
| + if (script.IsEmpty()) return;
|
| Local<Context> realm = Local<Context>::New(isolate, data->realms_[index]);
|
| realm->Enter();
|
| - Local<Value> result;
|
| - if (!script->BindToCurrentContext()->Run(realm).ToLocal(&result)) {
|
| - realm->Exit();
|
| - return;
|
| - }
|
| + Handle<Value> result = script->BindToCurrentContext()->Run();
|
| realm->Exit();
|
| args.GetReturnValue().Set(result);
|
| }
|
| @@ -625,10 +600,8 @@
|
|
|
| // Explicitly catch potential exceptions in toString().
|
| v8::TryCatch try_catch(args.GetIsolate());
|
| - Local<String> str_obj;
|
| - if (!args[i]
|
| - ->ToString(args.GetIsolate()->GetCurrentContext())
|
| - .ToLocal(&str_obj)) {
|
| + Handle<String> str_obj = args[i]->ToString(args.GetIsolate());
|
| + if (try_catch.HasCaught()) {
|
| try_catch.ReThrow();
|
| return;
|
| }
|
| @@ -649,7 +622,7 @@
|
| Throw(args.GetIsolate(), "Error loading file");
|
| return;
|
| }
|
| - Local<String> source = ReadFile(args.GetIsolate(), *file);
|
| + Handle<String> source = ReadFile(args.GetIsolate(), *file);
|
| if (source.IsEmpty()) {
|
| Throw(args.GetIsolate(), "Error loading file");
|
| return;
|
| @@ -658,11 +631,10 @@
|
| }
|
|
|
|
|
| -Local<String> Shell::ReadFromStdin(Isolate* isolate) {
|
| +Handle<String> Shell::ReadFromStdin(Isolate* isolate) {
|
| static const int kBufferSize = 256;
|
| char buffer[kBufferSize];
|
| - Local<String> accumulator =
|
| - String::NewFromUtf8(isolate, "", NewStringType::kNormal).ToLocalChecked();
|
| + Handle<String> accumulator = String::NewFromUtf8(isolate, "");
|
| int length;
|
| while (true) {
|
| // Continue reading if the line ends with an escape '\\' or the line has
|
| @@ -670,26 +642,23 @@
|
| // If fgets gets an error, just give up.
|
| char* input = NULL;
|
| input = fgets(buffer, kBufferSize, stdin);
|
| - if (input == NULL) return Local<String>();
|
| + if (input == NULL) return Handle<String>();
|
| length = static_cast<int>(strlen(buffer));
|
| if (length == 0) {
|
| return accumulator;
|
| } else if (buffer[length-1] != '\n') {
|
| accumulator = String::Concat(
|
| accumulator,
|
| - String::NewFromUtf8(isolate, buffer, NewStringType::kNormal, length)
|
| - .ToLocalChecked());
|
| + String::NewFromUtf8(isolate, buffer, String::kNormalString, length));
|
| } else if (length > 1 && buffer[length-2] == '\\') {
|
| buffer[length-2] = '\n';
|
| accumulator = String::Concat(
|
| - accumulator,
|
| - String::NewFromUtf8(isolate, buffer, NewStringType::kNormal,
|
| - length - 1).ToLocalChecked());
|
| + accumulator, String::NewFromUtf8(isolate, buffer,
|
| + String::kNormalString, length - 1));
|
| } else {
|
| return String::Concat(
|
| - accumulator,
|
| - String::NewFromUtf8(isolate, buffer, NewStringType::kNormal,
|
| - length - 1).ToLocalChecked());
|
| + accumulator, String::NewFromUtf8(isolate, buffer,
|
| + String::kNormalString, length - 1));
|
| }
|
| }
|
| }
|
| @@ -703,16 +672,16 @@
|
| Throw(args.GetIsolate(), "Error loading file");
|
| return;
|
| }
|
| - Local<String> source = ReadFile(args.GetIsolate(), *file);
|
| + Handle<String> source = ReadFile(args.GetIsolate(), *file);
|
| if (source.IsEmpty()) {
|
| Throw(args.GetIsolate(), "Error loading file");
|
| return;
|
| }
|
| - if (!ExecuteString(
|
| - args.GetIsolate(), source,
|
| - String::NewFromUtf8(args.GetIsolate(), *file,
|
| - NewStringType::kNormal).ToLocalChecked(),
|
| - false, true)) {
|
| + if (!ExecuteString(args.GetIsolate(),
|
| + source,
|
| + String::NewFromUtf8(args.GetIsolate(), *file),
|
| + false,
|
| + true)) {
|
| Throw(args.GetIsolate(), "Error executing file");
|
| return;
|
| }
|
| @@ -766,7 +735,7 @@
|
| Worker* worker =
|
| static_cast<Worker*>(Local<External>::Cast(this_value)->Value());
|
|
|
| - Local<Value> message = args[0];
|
| + Handle<Value> message = args[0];
|
| ObjectList to_transfer;
|
| if (args.Length() >= 2) {
|
| if (!args[1]->IsArray()) {
|
| @@ -774,10 +743,10 @@
|
| return;
|
| }
|
|
|
| - Local<Array> transfer = Local<Array>::Cast(args[1]);
|
| + Handle<Array> transfer = Handle<Array>::Cast(args[1]);
|
| uint32_t length = transfer->Length();
|
| for (uint32_t i = 0; i < length; ++i) {
|
| - Local<Value> element;
|
| + Handle<Value> element;
|
| if (transfer->Get(context, i).ToLocal(&element)) {
|
| if (!element->IsArrayBuffer() && !element->IsSharedArrayBuffer()) {
|
| Throw(isolate,
|
| @@ -786,7 +755,7 @@
|
| break;
|
| }
|
|
|
| - to_transfer.Add(Local<Object>::Cast(element));
|
| + to_transfer.Add(Handle<Object>::Cast(element));
|
| }
|
| }
|
| }
|
| @@ -843,9 +812,7 @@
|
|
|
|
|
| void Shell::QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args) {
|
| - int exit_code = (*args)[0]
|
| - ->Int32Value(args->GetIsolate()->GetCurrentContext())
|
| - .FromMaybe(0);
|
| + int exit_code = (*args)[0]->Int32Value();
|
| #ifndef V8_SHARED
|
| CleanupWorkers();
|
| #endif // !V8_SHARED
|
| @@ -862,15 +829,14 @@
|
|
|
| void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
| args.GetReturnValue().Set(
|
| - String::NewFromUtf8(args.GetIsolate(), V8::GetVersion(),
|
| - NewStringType::kNormal).ToLocalChecked());
|
| + String::NewFromUtf8(args.GetIsolate(), V8::GetVersion()));
|
| }
|
|
|
|
|
| void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) {
|
| HandleScope handle_scope(isolate);
|
| #ifndef V8_SHARED
|
| - Local<Context> utility_context;
|
| + Handle<Context> utility_context;
|
| bool enter_context = !isolate->InContext();
|
| if (enter_context) {
|
| utility_context = Local<Context>::New(isolate, utility_context_);
|
| @@ -879,7 +845,7 @@
|
| #endif // !V8_SHARED
|
| v8::String::Utf8Value exception(try_catch->Exception());
|
| const char* exception_string = ToCString(exception);
|
| - Local<Message> message = try_catch->Message();
|
| + Handle<Message> message = try_catch->Message();
|
| if (message.IsEmpty()) {
|
| // V8 didn't provide any extra information about this error; just
|
| // print the exception.
|
| @@ -888,31 +854,26 @@
|
| // Print (filename):(line number): (message).
|
| v8::String::Utf8Value filename(message->GetScriptOrigin().ResourceName());
|
| const char* filename_string = ToCString(filename);
|
| - int linenum =
|
| - message->GetLineNumber(isolate->GetCurrentContext()).FromJust();
|
| + int linenum = message->GetLineNumber();
|
| printf("%s:%i: %s\n", filename_string, linenum, exception_string);
|
| // Print line of source code.
|
| - v8::String::Utf8Value sourceline(
|
| - message->GetSourceLine(isolate->GetCurrentContext()).ToLocalChecked());
|
| + v8::String::Utf8Value sourceline(message->GetSourceLine());
|
| const char* sourceline_string = ToCString(sourceline);
|
| printf("%s\n", sourceline_string);
|
| // Print wavy underline (GetUnderline is deprecated).
|
| - int start =
|
| - message->GetStartColumn(isolate->GetCurrentContext()).FromJust();
|
| + int start = message->GetStartColumn();
|
| for (int i = 0; i < start; i++) {
|
| printf(" ");
|
| }
|
| - int end = message->GetEndColumn(isolate->GetCurrentContext()).FromJust();
|
| + int end = message->GetEndColumn();
|
| for (int i = start; i < end; i++) {
|
| printf("^");
|
| }
|
| printf("\n");
|
| - Local<Value> stack_trace_string;
|
| - if (try_catch->StackTrace(isolate->GetCurrentContext())
|
| - .ToLocal(&stack_trace_string)) {
|
| - v8::String::Utf8Value stack_trace(
|
| - Local<String>::Cast(stack_trace_string));
|
| - printf("%s\n", ToCString(stack_trace));
|
| + v8::String::Utf8Value stack_trace(try_catch->StackTrace());
|
| + if (stack_trace.length() > 0) {
|
| + const char* stack_trace_string = ToCString(stack_trace);
|
| + printf("%s\n", stack_trace_string);
|
| }
|
| }
|
| printf("\n");
|
| @@ -923,65 +884,53 @@
|
|
|
|
|
| #ifndef V8_SHARED
|
| -Local<Array> Shell::GetCompletions(Isolate* isolate, Local<String> text,
|
| - Local<String> full) {
|
| +Handle<Array> Shell::GetCompletions(Isolate* isolate,
|
| + Handle<String> text,
|
| + Handle<String> full) {
|
| EscapableHandleScope handle_scope(isolate);
|
| v8::Local<v8::Context> utility_context =
|
| v8::Local<v8::Context>::New(isolate, utility_context_);
|
| v8::Context::Scope context_scope(utility_context);
|
| - Local<Object> global = utility_context->Global();
|
| - Local<Value> fun = global->Get(utility_context,
|
| - String::NewFromUtf8(isolate, "GetCompletions",
|
| - NewStringType::kNormal)
|
| - .ToLocalChecked()).ToLocalChecked();
|
| + Handle<Object> global = utility_context->Global();
|
| + Local<Value> fun =
|
| + global->Get(String::NewFromUtf8(isolate, "GetCompletions"));
|
| static const int kArgc = 3;
|
| v8::Local<v8::Context> evaluation_context =
|
| v8::Local<v8::Context>::New(isolate, evaluation_context_);
|
| - Local<Value> argv[kArgc] = {evaluation_context->Global(), text, full};
|
| - Local<Value> val = Local<Function>::Cast(fun)
|
| - ->Call(utility_context, global, kArgc, argv)
|
| - .ToLocalChecked();
|
| + Handle<Value> argv[kArgc] = { evaluation_context->Global(), text, full };
|
| + Local<Value> val = Local<Function>::Cast(fun)->Call(global, kArgc, argv);
|
| return handle_scope.Escape(Local<Array>::Cast(val));
|
| }
|
|
|
|
|
| Local<Object> Shell::DebugMessageDetails(Isolate* isolate,
|
| - Local<String> message) {
|
| + Handle<String> message) {
|
| EscapableHandleScope handle_scope(isolate);
|
| v8::Local<v8::Context> context =
|
| v8::Local<v8::Context>::New(isolate, utility_context_);
|
| v8::Context::Scope context_scope(context);
|
| - Local<Object> global = context->Global();
|
| - Local<Value> fun =
|
| - global->Get(context, String::NewFromUtf8(isolate, "DebugMessageDetails",
|
| - NewStringType::kNormal)
|
| - .ToLocalChecked()).ToLocalChecked();
|
| + Handle<Object> global = context->Global();
|
| + Handle<Value> fun =
|
| + global->Get(String::NewFromUtf8(isolate, "DebugMessageDetails"));
|
| static const int kArgc = 1;
|
| - Local<Value> argv[kArgc] = {message};
|
| - Local<Value> val = Local<Function>::Cast(fun)
|
| - ->Call(context, global, kArgc, argv)
|
| - .ToLocalChecked();
|
| - return handle_scope.Escape(Local<Object>(Local<Object>::Cast(val)));
|
| + Handle<Value> argv[kArgc] = { message };
|
| + Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv);
|
| + return handle_scope.Escape(Local<Object>(Handle<Object>::Cast(val)));
|
| }
|
|
|
|
|
| Local<Value> Shell::DebugCommandToJSONRequest(Isolate* isolate,
|
| - Local<String> command) {
|
| + Handle<String> command) {
|
| EscapableHandleScope handle_scope(isolate);
|
| v8::Local<v8::Context> context =
|
| v8::Local<v8::Context>::New(isolate, utility_context_);
|
| v8::Context::Scope context_scope(context);
|
| - Local<Object> global = context->Global();
|
| - Local<Value> fun =
|
| - global->Get(context,
|
| - String::NewFromUtf8(isolate, "DebugCommandToJSONRequest",
|
| - NewStringType::kNormal).ToLocalChecked())
|
| - .ToLocalChecked();
|
| + Handle<Object> global = context->Global();
|
| + Handle<Value> fun =
|
| + global->Get(String::NewFromUtf8(isolate, "DebugCommandToJSONRequest"));
|
| static const int kArgc = 1;
|
| - Local<Value> argv[kArgc] = {command};
|
| - Local<Value> val = Local<Function>::Cast(fun)
|
| - ->Call(context, global, kArgc, argv)
|
| - .ToLocalChecked();
|
| + Handle<Value> argv[kArgc] = { command };
|
| + Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv);
|
| return handle_scope.Escape(Local<Value>(val));
|
| }
|
|
|
| @@ -1116,12 +1065,8 @@
|
| i::Handle<i::Context> debug_context = debug->debug_context();
|
| i::Handle<i::JSObject> js_debug
|
| = i::Handle<i::JSObject>(debug_context->global_object());
|
| - utility_context->Global()
|
| - ->Set(utility_context,
|
| - String::NewFromUtf8(isolate, "$debug", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - Utils::ToLocal(js_debug))
|
| - .FromJust();
|
| + utility_context->Global()->Set(String::NewFromUtf8(isolate, "$debug"),
|
| + Utils::ToLocal(js_debug));
|
| debug_context->set_security_token(
|
| reinterpret_cast<i::Isolate*>(isolate)->heap()->undefined_value());
|
|
|
| @@ -1131,17 +1076,15 @@
|
| i::NativesCollection<i::D8>::GetScriptSource(source_index);
|
| i::Vector<const char> shell_source_name =
|
| i::NativesCollection<i::D8>::GetScriptName(source_index);
|
| - Local<String> source =
|
| - String::NewFromUtf8(isolate, shell_source.start(), NewStringType::kNormal,
|
| - shell_source.length()).ToLocalChecked();
|
| - Local<String> name =
|
| + Handle<String> source =
|
| + String::NewFromUtf8(isolate, shell_source.start(), String::kNormalString,
|
| + shell_source.length());
|
| + Handle<String> name =
|
| String::NewFromUtf8(isolate, shell_source_name.start(),
|
| - NewStringType::kNormal,
|
| - shell_source_name.length()).ToLocalChecked();
|
| + String::kNormalString, shell_source_name.length());
|
| ScriptOrigin origin(name);
|
| - Local<Script> script =
|
| - Script::Compile(utility_context, source, &origin).ToLocalChecked();
|
| - script->Run(utility_context).ToLocalChecked();
|
| + Handle<Script> script = Script::Compile(source, &origin);
|
| + script->Run();
|
| // Mark the d8 shell script as native to avoid it showing up as normal source
|
| // in the debugger.
|
| i::Handle<i::Object> compiled_script = Utils::OpenHandle(*script);
|
| @@ -1158,123 +1101,76 @@
|
| #endif // !V8_SHARED
|
|
|
|
|
| -Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
|
| - Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate);
|
| - global_template->Set(
|
| - String::NewFromUtf8(isolate, "print", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, Print));
|
| - global_template->Set(
|
| - String::NewFromUtf8(isolate, "write", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, Write));
|
| - global_template->Set(
|
| - String::NewFromUtf8(isolate, "read", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, Read));
|
| - global_template->Set(
|
| - String::NewFromUtf8(isolate, "readbuffer", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, ReadBuffer));
|
| - global_template->Set(
|
| - String::NewFromUtf8(isolate, "readline", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, ReadLine));
|
| - global_template->Set(
|
| - String::NewFromUtf8(isolate, "load", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, Load));
|
| +Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
|
| + Handle<ObjectTemplate> global_template = ObjectTemplate::New(isolate);
|
| + global_template->Set(String::NewFromUtf8(isolate, "print"),
|
| + FunctionTemplate::New(isolate, Print));
|
| + global_template->Set(String::NewFromUtf8(isolate, "write"),
|
| + FunctionTemplate::New(isolate, Write));
|
| + global_template->Set(String::NewFromUtf8(isolate, "read"),
|
| + FunctionTemplate::New(isolate, Read));
|
| + global_template->Set(String::NewFromUtf8(isolate, "readbuffer"),
|
| + FunctionTemplate::New(isolate, ReadBuffer));
|
| + global_template->Set(String::NewFromUtf8(isolate, "readline"),
|
| + FunctionTemplate::New(isolate, ReadLine));
|
| + global_template->Set(String::NewFromUtf8(isolate, "load"),
|
| + FunctionTemplate::New(isolate, Load));
|
| // Some Emscripten-generated code tries to call 'quit', which in turn would
|
| // call C's exit(). This would lead to memory leaks, because there is no way
|
| // we can terminate cleanly then, so we need a way to hide 'quit'.
|
| if (!options.omit_quit) {
|
| - global_template->Set(
|
| - String::NewFromUtf8(isolate, "quit", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, Quit));
|
| - }
|
| - global_template->Set(
|
| - String::NewFromUtf8(isolate, "version", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, Version));
|
| + global_template->Set(String::NewFromUtf8(isolate, "quit"),
|
| + FunctionTemplate::New(isolate, Quit));
|
| + }
|
| + global_template->Set(String::NewFromUtf8(isolate, "version"),
|
| + FunctionTemplate::New(isolate, Version));
|
|
|
| // Bind the Realm object.
|
| - Local<ObjectTemplate> realm_template = ObjectTemplate::New(isolate);
|
| - realm_template->Set(
|
| - String::NewFromUtf8(isolate, "current", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, RealmCurrent));
|
| - realm_template->Set(
|
| - String::NewFromUtf8(isolate, "owner", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, RealmOwner));
|
| - realm_template->Set(
|
| - String::NewFromUtf8(isolate, "global", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, RealmGlobal));
|
| - realm_template->Set(
|
| - String::NewFromUtf8(isolate, "create", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, RealmCreate));
|
| - realm_template->Set(
|
| - String::NewFromUtf8(isolate, "dispose", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, RealmDispose));
|
| - realm_template->Set(
|
| - String::NewFromUtf8(isolate, "switch", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, RealmSwitch));
|
| - realm_template->Set(
|
| - String::NewFromUtf8(isolate, "eval", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, RealmEval));
|
| - realm_template->SetAccessor(
|
| - String::NewFromUtf8(isolate, "shared", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - RealmSharedGet, RealmSharedSet);
|
| - global_template->Set(
|
| - String::NewFromUtf8(isolate, "Realm", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - realm_template);
|
| -
|
| -#ifndef V8_SHARED
|
| - Local<ObjectTemplate> performance_template = ObjectTemplate::New(isolate);
|
| - performance_template->Set(
|
| - String::NewFromUtf8(isolate, "now", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - FunctionTemplate::New(isolate, PerformanceNow));
|
| - global_template->Set(
|
| - String::NewFromUtf8(isolate, "performance", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - performance_template);
|
| -
|
| - Local<FunctionTemplate> worker_fun_template =
|
| + Handle<ObjectTemplate> realm_template = ObjectTemplate::New(isolate);
|
| + realm_template->Set(String::NewFromUtf8(isolate, "current"),
|
| + FunctionTemplate::New(isolate, RealmCurrent));
|
| + realm_template->Set(String::NewFromUtf8(isolate, "owner"),
|
| + FunctionTemplate::New(isolate, RealmOwner));
|
| + realm_template->Set(String::NewFromUtf8(isolate, "global"),
|
| + FunctionTemplate::New(isolate, RealmGlobal));
|
| + realm_template->Set(String::NewFromUtf8(isolate, "create"),
|
| + FunctionTemplate::New(isolate, RealmCreate));
|
| + realm_template->Set(String::NewFromUtf8(isolate, "dispose"),
|
| + FunctionTemplate::New(isolate, RealmDispose));
|
| + realm_template->Set(String::NewFromUtf8(isolate, "switch"),
|
| + FunctionTemplate::New(isolate, RealmSwitch));
|
| + realm_template->Set(String::NewFromUtf8(isolate, "eval"),
|
| + FunctionTemplate::New(isolate, RealmEval));
|
| + realm_template->SetAccessor(String::NewFromUtf8(isolate, "shared"),
|
| + RealmSharedGet, RealmSharedSet);
|
| + global_template->Set(String::NewFromUtf8(isolate, "Realm"), realm_template);
|
| +
|
| +#ifndef V8_SHARED
|
| + Handle<ObjectTemplate> performance_template = ObjectTemplate::New(isolate);
|
| + performance_template->Set(String::NewFromUtf8(isolate, "now"),
|
| + FunctionTemplate::New(isolate, PerformanceNow));
|
| + global_template->Set(String::NewFromUtf8(isolate, "performance"),
|
| + performance_template);
|
| +
|
| + Handle<FunctionTemplate> worker_fun_template =
|
| FunctionTemplate::New(isolate, WorkerNew);
|
| worker_fun_template->PrototypeTemplate()->Set(
|
| - String::NewFromUtf8(isolate, "terminate", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| + String::NewFromUtf8(isolate, "terminate"),
|
| FunctionTemplate::New(isolate, WorkerTerminate));
|
| worker_fun_template->PrototypeTemplate()->Set(
|
| - String::NewFromUtf8(isolate, "postMessage", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| + String::NewFromUtf8(isolate, "postMessage"),
|
| FunctionTemplate::New(isolate, WorkerPostMessage));
|
| worker_fun_template->PrototypeTemplate()->Set(
|
| - String::NewFromUtf8(isolate, "getMessage", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| + String::NewFromUtf8(isolate, "getMessage"),
|
| FunctionTemplate::New(isolate, WorkerGetMessage));
|
| worker_fun_template->InstanceTemplate()->SetInternalFieldCount(1);
|
| - global_template->Set(
|
| - String::NewFromUtf8(isolate, "Worker", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - worker_fun_template);
|
| -#endif // !V8_SHARED
|
| -
|
| - Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate);
|
| + global_template->Set(String::NewFromUtf8(isolate, "Worker"),
|
| + worker_fun_template);
|
| +#endif // !V8_SHARED
|
| +
|
| + Handle<ObjectTemplate> os_templ = ObjectTemplate::New(isolate);
|
| AddOSMethods(isolate, os_templ);
|
| - global_template->Set(
|
| - String::NewFromUtf8(isolate, "os", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - os_templ);
|
| + global_template->Set(String::NewFromUtf8(isolate, "os"), os_templ);
|
|
|
| return global_template;
|
| }
|
| @@ -1293,7 +1189,7 @@
|
| if (options.test_shell) return;
|
| #ifndef V8_SHARED
|
| HandleScope scope(isolate);
|
| - Local<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
|
| + Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
|
| utility_context_.Reset(isolate,
|
| Context::New(isolate, NULL, global_template));
|
| if (utility_context_.IsEmpty()) {
|
| @@ -1310,7 +1206,7 @@
|
| base::LockGuard<base::Mutex> lock_guard(context_mutex_.Pointer());
|
| #endif // !V8_SHARED
|
| // Initialize the global objects
|
| - Local<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
|
| + Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
|
| EscapableHandleScope handle_scope(isolate);
|
| Local<Context> context = Context::New(isolate, NULL, global_template);
|
| DCHECK(!context.IsEmpty());
|
| @@ -1328,12 +1224,8 @@
|
| }
|
| i::Handle<i::JSArray> arguments_jsarray =
|
| factory->NewJSArrayWithElements(arguments_array);
|
| - context->Global()
|
| - ->Set(context,
|
| - String::NewFromUtf8(isolate, "arguments", NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - Utils::ToLocal(arguments_jsarray))
|
| - .FromJust();
|
| + context->Global()->Set(String::NewFromUtf8(isolate, "arguments"),
|
| + Utils::ToLocal(arguments_jsarray));
|
| #endif // !V8_SHARED
|
| return handle_scope.Escape(context);
|
| }
|
| @@ -1488,7 +1380,8 @@
|
| return;
|
| }
|
| data->byte_length = length;
|
| - Local<v8::ArrayBuffer> buffer = ArrayBuffer::New(isolate, data->data, length);
|
| + Handle<v8::ArrayBuffer> buffer =
|
| + ArrayBuffer::New(isolate, data->data, length);
|
| data->handle.Reset(isolate, buffer);
|
| data->handle.SetWeak(data, ReadBufferWeakCallback,
|
| v8::WeakCallbackType::kParameter);
|
| @@ -1500,13 +1393,12 @@
|
|
|
|
|
| // Reads a file into a v8 string.
|
| -Local<String> Shell::ReadFile(Isolate* isolate, const char* name) {
|
| +Handle<String> Shell::ReadFile(Isolate* isolate, const char* name) {
|
| int size = 0;
|
| char* chars = ReadChars(isolate, name, &size);
|
| - if (chars == NULL) return Local<String>();
|
| - Local<String> result =
|
| - String::NewFromUtf8(isolate, chars, NewStringType::kNormal, size)
|
| - .ToLocalChecked();
|
| + if (chars == NULL) return Handle<String>();
|
| + Handle<String> result =
|
| + String::NewFromUtf8(isolate, chars, String::kNormalString, size);
|
| delete[] chars;
|
| return result;
|
| }
|
| @@ -1518,15 +1410,13 @@
|
| v8::Local<v8::Context>::New(isolate, evaluation_context_);
|
| v8::Context::Scope context_scope(context);
|
| PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
|
| - Local<String> name =
|
| - String::NewFromUtf8(isolate, "(d8)", NewStringType::kNormal)
|
| - .ToLocalChecked();
|
| + Handle<String> name = String::NewFromUtf8(isolate, "(d8)");
|
| LineEditor* console = LineEditor::Get();
|
| printf("V8 version %s [console: %s]\n", V8::GetVersion(), console->name());
|
| console->Open(isolate);
|
| while (true) {
|
| HandleScope inner_scope(isolate);
|
| - Local<String> input = console->Prompt(Shell::kPrompt);
|
| + Handle<String> input = console->Prompt(Shell::kPrompt);
|
| if (input.IsEmpty()) break;
|
| ExecuteString(isolate, input, name, true, true);
|
| }
|
| @@ -1550,12 +1440,8 @@
|
| if (strcmp(arg, "-e") == 0 && i + 1 < end_offset_) {
|
| // Execute argument given to -e option directly.
|
| HandleScope handle_scope(isolate);
|
| - Local<String> file_name =
|
| - String::NewFromUtf8(isolate, "unnamed", NewStringType::kNormal)
|
| - .ToLocalChecked();
|
| - Local<String> source =
|
| - String::NewFromUtf8(isolate, argv_[i + 1], NewStringType::kNormal)
|
| - .ToLocalChecked();
|
| + Handle<String> file_name = String::NewFromUtf8(isolate, "unnamed");
|
| + Handle<String> source = String::NewFromUtf8(isolate, argv_[i + 1]);
|
| if (!Shell::ExecuteString(isolate, source, file_name, false, true)) {
|
| exception_was_thrown = true;
|
| break;
|
| @@ -1573,10 +1459,8 @@
|
|
|
| // Use all other arguments as names of files to load and run.
|
| HandleScope handle_scope(isolate);
|
| - Local<String> file_name =
|
| - String::NewFromUtf8(isolate, arg, NewStringType::kNormal)
|
| - .ToLocalChecked();
|
| - Local<String> source = ReadFile(isolate, arg);
|
| + Handle<String> file_name = String::NewFromUtf8(isolate, arg);
|
| + Handle<String> source = ReadFile(isolate, arg);
|
| if (source.IsEmpty()) {
|
| printf("Error reading '%s'\n", arg);
|
| Shell::Exit(1);
|
| @@ -1593,13 +1477,12 @@
|
| }
|
|
|
|
|
| -Local<String> SourceGroup::ReadFile(Isolate* isolate, const char* name) {
|
| +Handle<String> SourceGroup::ReadFile(Isolate* isolate, const char* name) {
|
| int size;
|
| char* chars = ReadChars(isolate, name, &size);
|
| - if (chars == NULL) return Local<String>();
|
| - Local<String> result =
|
| - String::NewFromUtf8(isolate, chars, NewStringType::kNormal, size)
|
| - .ToLocalChecked();
|
| + if (chars == NULL) return Handle<String>();
|
| + Handle<String> result =
|
| + String::NewFromUtf8(isolate, chars, String::kNormalString, size);
|
| delete[] chars;
|
| return result;
|
| }
|
| @@ -1852,35 +1735,27 @@
|
| Context::Scope cscope(context);
|
| PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
|
|
|
| - Local<Object> global = context->Global();
|
| - Local<Value> this_value = External::New(isolate, this);
|
| - Local<FunctionTemplate> postmessage_fun_template =
|
| + Handle<Object> global = context->Global();
|
| + Handle<Value> this_value = External::New(isolate, this);
|
| + Handle<FunctionTemplate> postmessage_fun_template =
|
| FunctionTemplate::New(isolate, PostMessageOut, this_value);
|
|
|
| - Local<Function> postmessage_fun;
|
| + Handle<Function> postmessage_fun;
|
| if (postmessage_fun_template->GetFunction(context)
|
| .ToLocal(&postmessage_fun)) {
|
| - global->Set(context, String::NewFromUtf8(isolate, "postMessage",
|
| - NewStringType::kNormal)
|
| - .ToLocalChecked(),
|
| - postmessage_fun).FromJust();
|
| + global->Set(String::NewFromUtf8(isolate, "postMessage"),
|
| + postmessage_fun);
|
| }
|
|
|
| // First run the script
|
| - Local<String> file_name =
|
| - String::NewFromUtf8(isolate, "unnamed", NewStringType::kNormal)
|
| - .ToLocalChecked();
|
| - Local<String> source =
|
| - String::NewFromUtf8(isolate, script_, NewStringType::kNormal)
|
| - .ToLocalChecked();
|
| + Handle<String> file_name = String::NewFromUtf8(isolate, "unnamed");
|
| + Handle<String> source = String::NewFromUtf8(isolate, script_);
|
| if (Shell::ExecuteString(isolate, source, file_name, false, true)) {
|
| // Get the message handler
|
| - Local<Value> onmessage =
|
| - global->Get(context, String::NewFromUtf8(isolate, "onmessage",
|
| - NewStringType::kNormal)
|
| - .ToLocalChecked()).ToLocalChecked();
|
| + Handle<Value> onmessage =
|
| + global->Get(String::NewFromUtf8(isolate, "onmessage"));
|
| if (onmessage->IsFunction()) {
|
| - Local<Function> onmessage_fun = Local<Function>::Cast(onmessage);
|
| + Handle<Function> onmessage_fun = Handle<Function>::Cast(onmessage);
|
| // Now wait for messages
|
| while (true) {
|
| in_semaphore_.Wait();
|
| @@ -1893,7 +1768,7 @@
|
| Local<Value> data_value;
|
| if (Shell::DeserializeValue(isolate, *data, &offset)
|
| .ToLocal(&data_value)) {
|
| - Local<Value> argv[] = {data_value};
|
| + Handle<Value> argv[] = {data_value};
|
| (void)onmessage_fun->Call(context, global, 1, argv);
|
| }
|
| delete data;
|
| @@ -1921,7 +1796,7 @@
|
| return;
|
| }
|
|
|
| - Local<Value> message = args[0];
|
| + Handle<Value> message = args[0];
|
|
|
| // TODO(binji): Allow transferring from worker to main thread?
|
| Shell::ObjectList to_transfer;
|
| @@ -1931,7 +1806,7 @@
|
| if (Shell::SerializeValue(isolate, message, to_transfer, &seen_objects,
|
| data)) {
|
| DCHECK(args.Data()->IsExternal());
|
| - Local<External> this_value = Local<External>::Cast(args.Data());
|
| + Handle<External> this_value = Handle<External>::Cast(args.Data());
|
| Worker* worker = static_cast<Worker*>(this_value->Value());
|
| worker->out_queue_.Enqueue(data);
|
| worker->out_semaphore_.Signal();
|
| @@ -2141,7 +2016,7 @@
|
|
|
|
|
| #ifndef V8_SHARED
|
| -bool Shell::SerializeValue(Isolate* isolate, Local<Value> value,
|
| +bool Shell::SerializeValue(Isolate* isolate, Handle<Value> value,
|
| const ObjectList& to_transfer,
|
| ObjectList* seen_objects,
|
| SerializationData* out_data) {
|
| @@ -2157,7 +2032,7 @@
|
| } else if (value->IsFalse()) {
|
| out_data->WriteTag(kSerializationTagFalse);
|
| } else if (value->IsNumber()) {
|
| - Local<Number> num = Local<Number>::Cast(value);
|
| + Handle<Number> num = Handle<Number>::Cast(value);
|
| double value = num->Value();
|
| out_data->WriteTag(kSerializationTagNumber);
|
| out_data->Write(value);
|
| @@ -2167,7 +2042,7 @@
|
| out_data->Write(str.length());
|
| out_data->WriteMemory(*str, str.length());
|
| } else if (value->IsArray()) {
|
| - Local<Array> array = Local<Array>::Cast(value);
|
| + Handle<Array> array = Handle<Array>::Cast(value);
|
| if (FindInObjectList(array, *seen_objects)) {
|
| Throw(isolate, "Duplicated arrays not supported");
|
| return false;
|
| @@ -2188,7 +2063,7 @@
|
| }
|
| }
|
| } else if (value->IsArrayBuffer()) {
|
| - Local<ArrayBuffer> array_buffer = Local<ArrayBuffer>::Cast(value);
|
| + Handle<ArrayBuffer> array_buffer = Handle<ArrayBuffer>::Cast(value);
|
| if (FindInObjectList(array_buffer, *seen_objects)) {
|
| Throw(isolate, "Duplicated array buffers not supported");
|
| return false;
|
| @@ -2221,7 +2096,7 @@
|
| static_cast<int>(contents.ByteLength()));
|
| }
|
| } else if (value->IsSharedArrayBuffer()) {
|
| - Local<SharedArrayBuffer> sab = Local<SharedArrayBuffer>::Cast(value);
|
| + Handle<SharedArrayBuffer> sab = Handle<SharedArrayBuffer>::Cast(value);
|
| if (FindInObjectList(sab, *seen_objects)) {
|
| Throw(isolate, "Duplicated shared array buffers not supported");
|
| return false;
|
| @@ -2241,7 +2116,7 @@
|
| }
|
| out_data->WriteSharedArrayBufferContents(contents);
|
| } else if (value->IsObject()) {
|
| - Local<Object> object = Local<Object>::Cast(value);
|
| + Handle<Object> object = Handle<Object>::Cast(value);
|
| if (FindInObjectList(object, *seen_objects)) {
|
| Throw(isolate, "Duplicated objects not supported");
|
| return false;
|
| @@ -2257,8 +2132,8 @@
|
| out_data->WriteTag(kSerializationTagObject);
|
| out_data->Write(length);
|
| for (uint32_t i = 0; i < length; ++i) {
|
| - Local<Value> name;
|
| - Local<Value> property_value;
|
| + Handle<Value> name;
|
| + Handle<Value> property_value;
|
| if (property_names->Get(context, i).ToLocal(&name) &&
|
| object->Get(context, name).ToLocal(&property_value)) {
|
| if (!SerializeValue(isolate, name, to_transfer, seen_objects, out_data))
|
| @@ -2311,40 +2186,38 @@
|
| CHECK(length >= 0);
|
| std::vector<char> buffer(length + 1); // + 1 so it is never empty.
|
| data.ReadMemory(&buffer[0], length, offset);
|
| - MaybeLocal<String> str =
|
| - String::NewFromUtf8(isolate, &buffer[0], NewStringType::kNormal,
|
| - length).ToLocalChecked();
|
| + MaybeLocal<String> str = String::NewFromUtf8(
|
| + isolate, &buffer[0], String::kNormalString, length);
|
| if (!str.IsEmpty()) result = str.ToLocalChecked();
|
| break;
|
| }
|
| case kSerializationTagArray: {
|
| uint32_t length = data.Read<uint32_t>(offset);
|
| - Local<Array> array = Array::New(isolate, length);
|
| + Handle<Array> array = Array::New(isolate, length);
|
| for (uint32_t i = 0; i < length; ++i) {
|
| Local<Value> element_value;
|
| CHECK(DeserializeValue(isolate, data, offset).ToLocal(&element_value));
|
| - array->Set(isolate->GetCurrentContext(), i, element_value).FromJust();
|
| + array->Set(i, element_value);
|
| }
|
| result = array;
|
| break;
|
| }
|
| case kSerializationTagObject: {
|
| int length = data.Read<int>(offset);
|
| - Local<Object> object = Object::New(isolate);
|
| + Handle<Object> object = Object::New(isolate);
|
| for (int i = 0; i < length; ++i) {
|
| Local<Value> property_name;
|
| CHECK(DeserializeValue(isolate, data, offset).ToLocal(&property_name));
|
| Local<Value> property_value;
|
| CHECK(DeserializeValue(isolate, data, offset).ToLocal(&property_value));
|
| - object->Set(isolate->GetCurrentContext(), property_name, property_value)
|
| - .FromJust();
|
| + object->Set(property_name, property_value);
|
| }
|
| result = object;
|
| break;
|
| }
|
| case kSerializationTagArrayBuffer: {
|
| int byte_length = data.Read<int>(offset);
|
| - Local<ArrayBuffer> array_buffer = ArrayBuffer::New(isolate, byte_length);
|
| + Handle<ArrayBuffer> array_buffer = ArrayBuffer::New(isolate, byte_length);
|
| ArrayBuffer::Contents contents = array_buffer->GetContents();
|
| DCHECK(static_cast<size_t>(byte_length) == contents.ByteLength());
|
| data.ReadMemory(contents.Data(), byte_length, offset);
|
|
|