Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: src/api.cc

Issue 2628093003: [serializer] change internal field callbacks to take data pointer. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/v8.h ('k') | src/debug/debug.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 #endif // DEBUG 608 #endif // DEBUG
609 609
610 i::StartupSerializer startup_serializer(isolate, function_code_handling); 610 i::StartupSerializer startup_serializer(isolate, function_code_handling);
611 startup_serializer.SerializeStrongReferences(); 611 startup_serializer.SerializeStrongReferences();
612 612
613 // Serialize each context with a new partial serializer. 613 // Serialize each context with a new partial serializer.
614 i::List<i::SnapshotData*> context_snapshots(num_additional_contexts + 1); 614 i::List<i::SnapshotData*> context_snapshots(num_additional_contexts + 1);
615 615
616 { 616 {
617 // The default snapshot does not support internal fields. 617 // The default snapshot does not support internal fields.
618 i::PartialSerializer partial_serializer(isolate, &startup_serializer, 618 i::PartialSerializer partial_serializer(
619 nullptr); 619 isolate, &startup_serializer, v8::SerializeInternalFieldsCallback());
620 partial_serializer.Serialize(&default_context, false); 620 partial_serializer.Serialize(&default_context, false);
621 context_snapshots.Add(new i::SnapshotData(&partial_serializer)); 621 context_snapshots.Add(new i::SnapshotData(&partial_serializer));
622 } 622 }
623 623
624 for (int i = 0; i < num_additional_contexts; i++) { 624 for (int i = 0; i < num_additional_contexts; i++) {
625 i::PartialSerializer partial_serializer( 625 i::PartialSerializer partial_serializer(
626 isolate, &startup_serializer, data->internal_fields_serializers_[i]); 626 isolate, &startup_serializer, data->internal_fields_serializers_[i]);
627 partial_serializer.Serialize(&contexts[i], true); 627 partial_serializer.Serialize(&contexts[i], true);
628 context_snapshots.Add(new i::SnapshotData(&partial_serializer)); 628 context_snapshots.Add(new i::SnapshotData(&partial_serializer));
629 } 629 }
(...skipping 5660 matching lines...) Expand 10 before | Expand all | Expand 10 after
6290 return Local<Context>(); 6290 return Local<Context>();
6291 } 6291 }
6292 return Utils::ToLocal(scope.CloseAndEscape(env)); 6292 return Utils::ToLocal(scope.CloseAndEscape(env));
6293 } 6293 }
6294 6294
6295 Local<Context> v8::Context::New(v8::Isolate* external_isolate, 6295 Local<Context> v8::Context::New(v8::Isolate* external_isolate,
6296 v8::ExtensionConfiguration* extensions, 6296 v8::ExtensionConfiguration* extensions,
6297 v8::MaybeLocal<ObjectTemplate> global_template, 6297 v8::MaybeLocal<ObjectTemplate> global_template,
6298 v8::MaybeLocal<Value> global_object) { 6298 v8::MaybeLocal<Value> global_object) {
6299 return NewContext(external_isolate, extensions, global_template, 6299 return NewContext(external_isolate, extensions, global_template,
6300 global_object, 0, nullptr); 6300 global_object, 0, DeserializeInternalFieldsCallback());
6301 } 6301 }
6302 6302
6303 MaybeLocal<Context> v8::Context::FromSnapshot( 6303 MaybeLocal<Context> v8::Context::FromSnapshot(
6304 v8::Isolate* external_isolate, size_t context_snapshot_index, 6304 v8::Isolate* external_isolate, size_t context_snapshot_index,
6305 v8::DeserializeInternalFieldsCallback internal_fields_deserializer, 6305 v8::DeserializeInternalFieldsCallback internal_fields_deserializer,
6306 v8::ExtensionConfiguration* extensions, MaybeLocal<Value> global_object) { 6306 v8::ExtensionConfiguration* extensions, MaybeLocal<Value> global_object) {
6307 size_t index_including_default_context = context_snapshot_index + 1; 6307 size_t index_including_default_context = context_snapshot_index + 1;
6308 if (!i::Snapshot::HasContextSnapshot( 6308 if (!i::Snapshot::HasContextSnapshot(
6309 reinterpret_cast<i::Isolate*>(external_isolate), 6309 reinterpret_cast<i::Isolate*>(external_isolate),
6310 index_including_default_context)) { 6310 index_including_default_context)) {
(...skipping 16 matching lines...) Expand all
6327 "v8::Context::NewRemoteContext", 6327 "v8::Context::NewRemoteContext",
6328 "Global template needs to have access checks enabled."); 6328 "Global template needs to have access checks enabled.");
6329 i::Handle<i::AccessCheckInfo> access_check_info = i::handle( 6329 i::Handle<i::AccessCheckInfo> access_check_info = i::handle(
6330 i::AccessCheckInfo::cast(global_constructor->access_check_info()), 6330 i::AccessCheckInfo::cast(global_constructor->access_check_info()),
6331 isolate); 6331 isolate);
6332 Utils::ApiCheck(access_check_info->named_interceptor() != nullptr, 6332 Utils::ApiCheck(access_check_info->named_interceptor() != nullptr,
6333 "v8::Context::NewRemoteContext", 6333 "v8::Context::NewRemoteContext",
6334 "Global template needs to have access check handlers."); 6334 "Global template needs to have access check handlers.");
6335 i::Handle<i::JSGlobalProxy> global_proxy = 6335 i::Handle<i::JSGlobalProxy> global_proxy =
6336 CreateEnvironment<i::JSGlobalProxy>(isolate, nullptr, global_template, 6336 CreateEnvironment<i::JSGlobalProxy>(isolate, nullptr, global_template,
6337 global_object, 0, nullptr); 6337 global_object, 0,
6338 DeserializeInternalFieldsCallback());
6338 if (global_proxy.is_null()) { 6339 if (global_proxy.is_null()) {
6339 if (isolate->has_pending_exception()) { 6340 if (isolate->has_pending_exception()) {
6340 isolate->OptionalRescheduleException(true); 6341 isolate->OptionalRescheduleException(true);
6341 } 6342 }
6342 return MaybeLocal<Object>(); 6343 return MaybeLocal<Object>();
6343 } 6344 }
6344 return Utils::ToLocal( 6345 return Utils::ToLocal(
6345 scope.CloseAndEscape(i::Handle<i::JSObject>::cast(global_proxy))); 6346 scope.CloseAndEscape(i::Handle<i::JSObject>::cast(global_proxy)));
6346 } 6347 }
6347 6348
(...skipping 3639 matching lines...) Expand 10 before | Expand all | Expand 10 after
9987 Address callback_address = 9988 Address callback_address =
9988 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9989 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9989 VMState<EXTERNAL> state(isolate); 9990 VMState<EXTERNAL> state(isolate);
9990 ExternalCallbackScope call_scope(isolate, callback_address); 9991 ExternalCallbackScope call_scope(isolate, callback_address);
9991 callback(info); 9992 callback(info);
9992 } 9993 }
9993 9994
9994 9995
9995 } // namespace internal 9996 } // namespace internal
9996 } // namespace v8 9997 } // namespace v8
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/debug/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698