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

Side by Side Diff: src/api.cc

Issue 791033002: Disallow object/function templates when creating snapshots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 | « no previous file | no next file » | 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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 return Utils::ToLocal(obj); 748 return Utils::ToLocal(obj);
749 } 749 }
750 750
751 Local<FunctionTemplate> FunctionTemplate::New( 751 Local<FunctionTemplate> FunctionTemplate::New(
752 Isolate* isolate, 752 Isolate* isolate,
753 FunctionCallback callback, 753 FunctionCallback callback,
754 v8::Handle<Value> data, 754 v8::Handle<Value> data,
755 v8::Handle<Signature> signature, 755 v8::Handle<Signature> signature,
756 int length) { 756 int length) {
757 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 757 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
758 // Changes to the environment cannot be captured in the snapshot. Expect no
759 // function templates when the isolate is created for serialization.
760 DCHECK(!i_isolate->serializer_enabled());
758 LOG_API(i_isolate, "FunctionTemplate::New"); 761 LOG_API(i_isolate, "FunctionTemplate::New");
759 ENTER_V8(i_isolate); 762 ENTER_V8(i_isolate);
760 return FunctionTemplateNew( 763 return FunctionTemplateNew(
761 i_isolate, callback, data, signature, length, false); 764 i_isolate, callback, data, signature, length, false);
762 } 765 }
763 766
764 767
765 Local<Signature> Signature::New(Isolate* isolate, 768 Local<Signature> Signature::New(Isolate* isolate,
766 Handle<FunctionTemplate> receiver, int argc, 769 Handle<FunctionTemplate> receiver, int argc,
767 Handle<FunctionTemplate> argv[]) { 770 Handle<FunctionTemplate> argv[]) {
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 1090
1088 1091
1089 Local<ObjectTemplate> ObjectTemplate::New() { 1092 Local<ObjectTemplate> ObjectTemplate::New() {
1090 return New(i::Isolate::Current(), Local<FunctionTemplate>()); 1093 return New(i::Isolate::Current(), Local<FunctionTemplate>());
1091 } 1094 }
1092 1095
1093 1096
1094 Local<ObjectTemplate> ObjectTemplate::New( 1097 Local<ObjectTemplate> ObjectTemplate::New(
1095 i::Isolate* isolate, 1098 i::Isolate* isolate,
1096 v8::Handle<FunctionTemplate> constructor) { 1099 v8::Handle<FunctionTemplate> constructor) {
1100 // Changes to the environment cannot be captured in the snapshot. Expect no
1101 // object templates when the isolate is created for serialization.
1102 DCHECK(!isolate->serializer_enabled());
1097 LOG_API(isolate, "ObjectTemplate::New"); 1103 LOG_API(isolate, "ObjectTemplate::New");
1098 ENTER_V8(isolate); 1104 ENTER_V8(isolate);
1099 i::Handle<i::Struct> struct_obj = 1105 i::Handle<i::Struct> struct_obj =
1100 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); 1106 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE);
1101 i::Handle<i::ObjectTemplateInfo> obj = 1107 i::Handle<i::ObjectTemplateInfo> obj =
1102 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); 1108 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj);
1103 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); 1109 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE);
1104 if (!constructor.IsEmpty()) 1110 if (!constructor.IsEmpty())
1105 obj->set_constructor(*Utils::OpenHandle(*constructor)); 1111 obj->set_constructor(*Utils::OpenHandle(*constructor));
1106 obj->set_internal_field_count(i::Smi::FromInt(0)); 1112 obj->set_internal_field_count(i::Smi::FromInt(0));
(...skipping 6588 matching lines...) Expand 10 before | Expand all | Expand 10 after
7695 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7701 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7696 Address callback_address = 7702 Address callback_address =
7697 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7703 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7698 VMState<EXTERNAL> state(isolate); 7704 VMState<EXTERNAL> state(isolate);
7699 ExternalCallbackScope call_scope(isolate, callback_address); 7705 ExternalCallbackScope call_scope(isolate, callback_address);
7700 callback(info); 7706 callback(info);
7701 } 7707 }
7702 7708
7703 7709
7704 } } // namespace v8::internal 7710 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698