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

Side by Side Diff: src/api.cc

Issue 582953002: Revert "Require V8 to be explicitly initialized before an Isolate is created" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « samples/shell.cc ('k') | src/base/utils/random-number-generator.h » ('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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) { 195 static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) {
196 if (!isolate->IsInitialized()) return false; 196 if (!isolate->IsInitialized()) return false;
197 if (isolate->has_scheduled_exception()) { 197 if (isolate->has_scheduled_exception()) {
198 return isolate->scheduled_exception() == 198 return isolate->scheduled_exception() ==
199 isolate->heap()->termination_exception(); 199 isolate->heap()->termination_exception();
200 } 200 }
201 return false; 201 return false;
202 } 202 }
203 203
204 204
205 // --- S t a t i c s ---
206
207
208 static bool InitializeHelper(i::Isolate* isolate) {
209 // If the isolate has a function entry hook, it needs to re-build all its
210 // code stubs with entry hooks embedded, so let's deserialize a snapshot.
211 if (isolate == NULL || isolate->function_entry_hook() == NULL) {
212 if (i::Snapshot::Initialize())
213 return true;
214 }
215 return i::V8::Initialize(NULL);
216 }
217
218
219 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate,
220 const char* location) {
221 return (isolate != NULL && isolate->IsInitialized()) ||
222 Utils::ApiCheck(InitializeHelper(isolate),
223 location,
224 "Error initializing V8");
225 }
226
227
205 StartupDataDecompressor::StartupDataDecompressor() 228 StartupDataDecompressor::StartupDataDecompressor()
206 : raw_data(i::NewArray<char*>(V8::GetCompressedStartupDataCount())) { 229 : raw_data(i::NewArray<char*>(V8::GetCompressedStartupDataCount())) {
207 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) { 230 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) {
208 raw_data[i] = NULL; 231 raw_data[i] = NULL;
209 } 232 }
210 } 233 }
211 234
212 235
213 StartupDataDecompressor::~StartupDataDecompressor() { 236 StartupDataDecompressor::~StartupDataDecompressor() {
214 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) { 237 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) {
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 739
717 // --- N e a n d e r --- 740 // --- N e a n d e r ---
718 741
719 742
720 // A constructor cannot easily return an error value, therefore it is necessary 743 // A constructor cannot easily return an error value, therefore it is necessary
721 // to check for a dead VM with ON_BAILOUT before constructing any Neander 744 // to check for a dead VM with ON_BAILOUT before constructing any Neander
722 // objects. To remind you about this there is no HandleScope in the 745 // objects. To remind you about this there is no HandleScope in the
723 // NeanderObject constructor. When you add one to the site calling the 746 // NeanderObject constructor. When you add one to the site calling the
724 // constructor you should check that you ensured the VM was not dead first. 747 // constructor you should check that you ensured the VM was not dead first.
725 NeanderObject::NeanderObject(v8::internal::Isolate* isolate, int size) { 748 NeanderObject::NeanderObject(v8::internal::Isolate* isolate, int size) {
749 EnsureInitializedForIsolate(isolate, "v8::Nowhere");
726 ENTER_V8(isolate); 750 ENTER_V8(isolate);
727 value_ = isolate->factory()->NewNeanderObject(); 751 value_ = isolate->factory()->NewNeanderObject();
728 i::Handle<i::FixedArray> elements = isolate->factory()->NewFixedArray(size); 752 i::Handle<i::FixedArray> elements = isolate->factory()->NewFixedArray(size);
729 value_->set_elements(*elements); 753 value_->set_elements(*elements);
730 } 754 }
731 755
732 756
733 int NeanderObject::size() { 757 int NeanderObject::size() {
734 return i::FixedArray::cast(value_->elements())->length(); 758 return i::FixedArray::cast(value_->elements())->length();
735 } 759 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 return Utils::ToLocal(obj); 932 return Utils::ToLocal(obj);
909 } 933 }
910 934
911 Local<FunctionTemplate> FunctionTemplate::New( 935 Local<FunctionTemplate> FunctionTemplate::New(
912 Isolate* isolate, 936 Isolate* isolate,
913 FunctionCallback callback, 937 FunctionCallback callback,
914 v8::Handle<Value> data, 938 v8::Handle<Value> data,
915 v8::Handle<Signature> signature, 939 v8::Handle<Signature> signature,
916 int length) { 940 int length) {
917 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 941 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
942 EnsureInitializedForIsolate(i_isolate, "v8::FunctionTemplate::New()");
918 LOG_API(i_isolate, "FunctionTemplate::New"); 943 LOG_API(i_isolate, "FunctionTemplate::New");
919 ENTER_V8(i_isolate); 944 ENTER_V8(i_isolate);
920 return FunctionTemplateNew( 945 return FunctionTemplateNew(
921 i_isolate, callback, data, signature, length, false); 946 i_isolate, callback, data, signature, length, false);
922 } 947 }
923 948
924 949
925 Local<Signature> Signature::New(Isolate* isolate, 950 Local<Signature> Signature::New(Isolate* isolate,
926 Handle<FunctionTemplate> receiver, int argc, 951 Handle<FunctionTemplate> receiver, int argc,
927 Handle<FunctionTemplate> argv[]) { 952 Handle<FunctionTemplate> argv[]) {
928 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 953 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
954 EnsureInitializedForIsolate(i_isolate, "v8::Signature::New()");
929 LOG_API(i_isolate, "Signature::New"); 955 LOG_API(i_isolate, "Signature::New");
930 ENTER_V8(i_isolate); 956 ENTER_V8(i_isolate);
931 i::Handle<i::Struct> struct_obj = 957 i::Handle<i::Struct> struct_obj =
932 i_isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE); 958 i_isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE);
933 i::Handle<i::SignatureInfo> obj = 959 i::Handle<i::SignatureInfo> obj =
934 i::Handle<i::SignatureInfo>::cast(struct_obj); 960 i::Handle<i::SignatureInfo>::cast(struct_obj);
935 if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver)); 961 if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver));
936 if (argc > 0) { 962 if (argc > 0) {
937 i::Handle<i::FixedArray> args = i_isolate->factory()->NewFixedArray(argc); 963 i::Handle<i::FixedArray> args = i_isolate->factory()->NewFixedArray(argc);
938 for (int i = 0; i < argc; i++) { 964 for (int i = 0; i < argc; i++) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 1095
1070 1096
1071 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) { 1097 Local<TypeSwitch> TypeSwitch::New(Handle<FunctionTemplate> type) {
1072 Handle<FunctionTemplate> types[1] = { type }; 1098 Handle<FunctionTemplate> types[1] = { type };
1073 return TypeSwitch::New(1, types); 1099 return TypeSwitch::New(1, types);
1074 } 1100 }
1075 1101
1076 1102
1077 Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) { 1103 Local<TypeSwitch> TypeSwitch::New(int argc, Handle<FunctionTemplate> types[]) {
1078 i::Isolate* isolate = i::Isolate::Current(); 1104 i::Isolate* isolate = i::Isolate::Current();
1105 EnsureInitializedForIsolate(isolate, "v8::TypeSwitch::New()");
1079 LOG_API(isolate, "TypeSwitch::New"); 1106 LOG_API(isolate, "TypeSwitch::New");
1080 ENTER_V8(isolate); 1107 ENTER_V8(isolate);
1081 i::Handle<i::FixedArray> vector = isolate->factory()->NewFixedArray(argc); 1108 i::Handle<i::FixedArray> vector = isolate->factory()->NewFixedArray(argc);
1082 for (int i = 0; i < argc; i++) 1109 for (int i = 0; i < argc; i++)
1083 vector->set(i, *Utils::OpenHandle(*types[i])); 1110 vector->set(i, *Utils::OpenHandle(*types[i]));
1084 i::Handle<i::Struct> struct_obj = 1111 i::Handle<i::Struct> struct_obj =
1085 isolate->factory()->NewStruct(i::TYPE_SWITCH_INFO_TYPE); 1112 isolate->factory()->NewStruct(i::TYPE_SWITCH_INFO_TYPE);
1086 i::Handle<i::TypeSwitchInfo> obj = 1113 i::Handle<i::TypeSwitchInfo> obj =
1087 i::Handle<i::TypeSwitchInfo>::cast(struct_obj); 1114 i::Handle<i::TypeSwitchInfo>::cast(struct_obj);
1088 obj->set_types(*vector); 1115 obj->set_types(*vector);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 1276
1250 1277
1251 Local<ObjectTemplate> ObjectTemplate::New() { 1278 Local<ObjectTemplate> ObjectTemplate::New() {
1252 return New(i::Isolate::Current(), Local<FunctionTemplate>()); 1279 return New(i::Isolate::Current(), Local<FunctionTemplate>());
1253 } 1280 }
1254 1281
1255 1282
1256 Local<ObjectTemplate> ObjectTemplate::New( 1283 Local<ObjectTemplate> ObjectTemplate::New(
1257 i::Isolate* isolate, 1284 i::Isolate* isolate,
1258 v8::Handle<FunctionTemplate> constructor) { 1285 v8::Handle<FunctionTemplate> constructor) {
1286 EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()");
1259 LOG_API(isolate, "ObjectTemplate::New"); 1287 LOG_API(isolate, "ObjectTemplate::New");
1260 ENTER_V8(isolate); 1288 ENTER_V8(isolate);
1261 i::Handle<i::Struct> struct_obj = 1289 i::Handle<i::Struct> struct_obj =
1262 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); 1290 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE);
1263 i::Handle<i::ObjectTemplateInfo> obj = 1291 i::Handle<i::ObjectTemplateInfo> obj =
1264 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); 1292 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj);
1265 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); 1293 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE);
1266 if (!constructor.IsEmpty()) 1294 if (!constructor.IsEmpty())
1267 obj->set_constructor(*Utils::OpenHandle(*constructor)); 1295 obj->set_constructor(*Utils::OpenHandle(*constructor));
1268 obj->set_internal_field_count(i::Smi::FromInt(0)); 1296 obj->set_internal_field_count(i::Smi::FromInt(0));
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 bool StackFrame::IsConstructor() const { 2393 bool StackFrame::IsConstructor() const {
2366 return getBoolProperty(this, "isConstructor"); 2394 return getBoolProperty(this, "isConstructor");
2367 } 2395 }
2368 2396
2369 2397
2370 // --- J S O N --- 2398 // --- J S O N ---
2371 2399
2372 Local<Value> JSON::Parse(Local<String> json_string) { 2400 Local<Value> JSON::Parse(Local<String> json_string) {
2373 i::Handle<i::String> string = Utils::OpenHandle(*json_string); 2401 i::Handle<i::String> string = Utils::OpenHandle(*json_string);
2374 i::Isolate* isolate = string->GetIsolate(); 2402 i::Isolate* isolate = string->GetIsolate();
2403 EnsureInitializedForIsolate(isolate, "v8::JSON::Parse");
2375 ENTER_V8(isolate); 2404 ENTER_V8(isolate);
2376 i::HandleScope scope(isolate); 2405 i::HandleScope scope(isolate);
2377 i::Handle<i::String> source = i::String::Flatten(string); 2406 i::Handle<i::String> source = i::String::Flatten(string);
2378 EXCEPTION_PREAMBLE(isolate); 2407 EXCEPTION_PREAMBLE(isolate);
2379 i::MaybeHandle<i::Object> maybe_result = 2408 i::MaybeHandle<i::Object> maybe_result =
2380 source->IsSeqOneByteString() ? i::JsonParser<true>::Parse(source) 2409 source->IsSeqOneByteString() ? i::JsonParser<true>::Parse(source)
2381 : i::JsonParser<false>::Parse(source); 2410 : i::JsonParser<false>::Parse(source);
2382 i::Handle<i::Object> result; 2411 i::Handle<i::Object> result;
2383 has_pending_exception = !maybe_result.ToHandle(&result); 2412 has_pending_exception = !maybe_result.ToHandle(&result);
2384 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); 2413 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
(...skipping 2470 matching lines...) Expand 10 before | Expand all | Expand 10 after
4855 int String::Write(uint16_t* buffer, 4884 int String::Write(uint16_t* buffer,
4856 int start, 4885 int start,
4857 int length, 4886 int length,
4858 int options) const { 4887 int options) const {
4859 return WriteHelper(this, buffer, start, length, options); 4888 return WriteHelper(this, buffer, start, length, options);
4860 } 4889 }
4861 4890
4862 4891
4863 bool v8::String::IsExternal() const { 4892 bool v8::String::IsExternal() const {
4864 i::Handle<i::String> str = Utils::OpenHandle(this); 4893 i::Handle<i::String> str = Utils::OpenHandle(this);
4894 EnsureInitializedForIsolate(str->GetIsolate(), "v8::String::IsExternal()");
4865 return i::StringShape(*str).IsExternalTwoByte(); 4895 return i::StringShape(*str).IsExternalTwoByte();
4866 } 4896 }
4867 4897
4868 4898
4869 bool v8::String::IsExternalOneByte() const { 4899 bool v8::String::IsExternalOneByte() const {
4870 i::Handle<i::String> str = Utils::OpenHandle(this); 4900 i::Handle<i::String> str = Utils::OpenHandle(this);
4871 return i::StringShape(*str).IsExternalOneByte(); 4901 return i::StringShape(*str).IsExternalOneByte();
4872 } 4902 }
4873 4903
4874 4904
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
5043 i::V8::InitializePlatform(platform); 5073 i::V8::InitializePlatform(platform);
5044 } 5074 }
5045 5075
5046 5076
5047 void v8::V8::ShutdownPlatform() { 5077 void v8::V8::ShutdownPlatform() {
5048 i::V8::ShutdownPlatform(); 5078 i::V8::ShutdownPlatform();
5049 } 5079 }
5050 5080
5051 5081
5052 bool v8::V8::Initialize() { 5082 bool v8::V8::Initialize() {
5053 i::V8::Initialize(); 5083 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
5054 return true; 5084 if (isolate != NULL && isolate->IsInitialized()) {
5085 return true;
5086 }
5087 return InitializeHelper(isolate);
5055 } 5088 }
5056 5089
5057 5090
5058 void v8::V8::SetEntropySource(EntropySource entropy_source) { 5091 void v8::V8::SetEntropySource(EntropySource entropy_source) {
5059 base::RandomNumberGenerator::SetEntropySource(entropy_source); 5092 base::RandomNumberGenerator::SetEntropySource(entropy_source);
5060 } 5093 }
5061 5094
5062 5095
5063 void v8::V8::SetReturnAddressLocationResolver( 5096 void v8::V8::SetReturnAddressLocationResolver(
5064 ReturnAddressLocationResolver return_address_resolver) { 5097 ReturnAddressLocationResolver return_address_resolver) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
5239 5272
5240 return env; 5273 return env;
5241 } 5274 }
5242 5275
5243 Local<Context> v8::Context::New( 5276 Local<Context> v8::Context::New(
5244 v8::Isolate* external_isolate, 5277 v8::Isolate* external_isolate,
5245 v8::ExtensionConfiguration* extensions, 5278 v8::ExtensionConfiguration* extensions,
5246 v8::Handle<ObjectTemplate> global_template, 5279 v8::Handle<ObjectTemplate> global_template,
5247 v8::Handle<Value> global_object) { 5280 v8::Handle<Value> global_object) {
5248 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate); 5281 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
5282 EnsureInitializedForIsolate(isolate, "v8::Context::New()");
5249 LOG_API(isolate, "Context::New"); 5283 LOG_API(isolate, "Context::New");
5250 ON_BAILOUT(isolate, "v8::Context::New()", return Local<Context>()); 5284 ON_BAILOUT(isolate, "v8::Context::New()", return Local<Context>());
5251 i::HandleScope scope(isolate); 5285 i::HandleScope scope(isolate);
5252 ExtensionConfiguration no_extensions; 5286 ExtensionConfiguration no_extensions;
5253 if (extensions == NULL) extensions = &no_extensions; 5287 if (extensions == NULL) extensions = &no_extensions;
5254 i::Handle<i::Context> env = 5288 i::Handle<i::Context> env =
5255 CreateEnvironment(isolate, extensions, global_template, global_object); 5289 CreateEnvironment(isolate, extensions, global_template, global_object);
5256 if (env.is_null()) return Local<Context>(); 5290 if (env.is_null()) return Local<Context>();
5257 return Utils::ToLocal(scope.CloseAndEscape(env)); 5291 return Utils::ToLocal(scope.CloseAndEscape(env));
5258 } 5292 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
5369 ON_BAILOUT(i::Isolate::Current(), "v8::FunctionTemplate::HasInstanceOf()", 5403 ON_BAILOUT(i::Isolate::Current(), "v8::FunctionTemplate::HasInstanceOf()",
5370 return false); 5404 return false);
5371 i::Object* obj = *Utils::OpenHandle(*value); 5405 i::Object* obj = *Utils::OpenHandle(*value);
5372 return Utils::OpenHandle(this)->IsTemplateFor(obj); 5406 return Utils::OpenHandle(this)->IsTemplateFor(obj);
5373 } 5407 }
5374 5408
5375 5409
5376 Local<External> v8::External::New(Isolate* isolate, void* value) { 5410 Local<External> v8::External::New(Isolate* isolate, void* value) {
5377 STATIC_ASSERT(sizeof(value) == sizeof(i::Address)); 5411 STATIC_ASSERT(sizeof(value) == sizeof(i::Address));
5378 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5412 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5413 EnsureInitializedForIsolate(i_isolate, "v8::External::New()");
5379 LOG_API(i_isolate, "External::New"); 5414 LOG_API(i_isolate, "External::New");
5380 ENTER_V8(i_isolate); 5415 ENTER_V8(i_isolate);
5381 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value); 5416 i::Handle<i::JSObject> external = i_isolate->factory()->NewExternal(value);
5382 return Utils::ExternalToLocal(external); 5417 return Utils::ExternalToLocal(external);
5383 } 5418 }
5384 5419
5385 5420
5386 void* External::Value() const { 5421 void* External::Value() const {
5387 return ExternalValue(*Utils::OpenHandle(this)); 5422 return ExternalValue(*Utils::OpenHandle(this));
5388 } 5423 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
5443 5478
5444 5479
5445 template<typename Char> 5480 template<typename Char>
5446 inline Local<String> NewString(Isolate* v8_isolate, 5481 inline Local<String> NewString(Isolate* v8_isolate,
5447 const char* location, 5482 const char* location,
5448 const char* env, 5483 const char* env,
5449 const Char* data, 5484 const Char* data,
5450 String::NewStringType type, 5485 String::NewStringType type,
5451 int length) { 5486 int length) {
5452 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate); 5487 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate);
5488 EnsureInitializedForIsolate(isolate, location);
5453 LOG_API(isolate, env); 5489 LOG_API(isolate, env);
5454 if (length == 0 && type != String::kUndetectableString) { 5490 if (length == 0 && type != String::kUndetectableString) {
5455 return String::Empty(v8_isolate); 5491 return String::Empty(v8_isolate);
5456 } 5492 }
5457 ENTER_V8(isolate); 5493 ENTER_V8(isolate);
5458 if (length == -1) length = StringLength(data); 5494 if (length == -1) length = StringLength(data);
5459 // We do not expect this to fail. Change this if it does. 5495 // We do not expect this to fail. Change this if it does.
5460 i::Handle<i::String> result = NewString( 5496 i::Handle<i::String> result = NewString(
5461 isolate->factory(), 5497 isolate->factory(),
5462 type, 5498 type,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
5505 "String::NewFromTwoByte", 5541 "String::NewFromTwoByte",
5506 data, 5542 data,
5507 type, 5543 type,
5508 length); 5544 length);
5509 } 5545 }
5510 5546
5511 5547
5512 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { 5548 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) {
5513 i::Handle<i::String> left_string = Utils::OpenHandle(*left); 5549 i::Handle<i::String> left_string = Utils::OpenHandle(*left);
5514 i::Isolate* isolate = left_string->GetIsolate(); 5550 i::Isolate* isolate = left_string->GetIsolate();
5551 EnsureInitializedForIsolate(isolate, "v8::String::New()");
5515 LOG_API(isolate, "String::New(char)"); 5552 LOG_API(isolate, "String::New(char)");
5516 ENTER_V8(isolate); 5553 ENTER_V8(isolate);
5517 i::Handle<i::String> right_string = Utils::OpenHandle(*right); 5554 i::Handle<i::String> right_string = Utils::OpenHandle(*right);
5518 // We do not expect this to fail. Change this if it does. 5555 // We do not expect this to fail. Change this if it does.
5519 i::Handle<i::String> result = isolate->factory()->NewConsString( 5556 i::Handle<i::String> result = isolate->factory()->NewConsString(
5520 left_string, right_string).ToHandleChecked(); 5557 left_string, right_string).ToHandleChecked();
5521 return Utils::ToLocal(result); 5558 return Utils::ToLocal(result);
5522 } 5559 }
5523 5560
5524 5561
(...skipping 12 matching lines...) Expand all
5537 return isolate->factory() 5574 return isolate->factory()
5538 ->NewExternalStringFromOneByte(resource) 5575 ->NewExternalStringFromOneByte(resource)
5539 .ToHandleChecked(); 5576 .ToHandleChecked();
5540 } 5577 }
5541 5578
5542 5579
5543 Local<String> v8::String::NewExternal( 5580 Local<String> v8::String::NewExternal(
5544 Isolate* isolate, 5581 Isolate* isolate,
5545 v8::String::ExternalStringResource* resource) { 5582 v8::String::ExternalStringResource* resource) {
5546 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5583 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5584 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()");
5547 LOG_API(i_isolate, "String::NewExternal"); 5585 LOG_API(i_isolate, "String::NewExternal");
5548 ENTER_V8(i_isolate); 5586 ENTER_V8(i_isolate);
5549 CHECK(resource && resource->data()); 5587 CHECK(resource && resource->data());
5550 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); 5588 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource);
5551 i_isolate->heap()->external_string_table()->AddString(*result); 5589 i_isolate->heap()->external_string_table()->AddString(*result);
5552 return Utils::ToLocal(result); 5590 return Utils::ToLocal(result);
5553 } 5591 }
5554 5592
5555 5593
5556 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { 5594 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
(...skipping 18 matching lines...) Expand all
5575 DCHECK(obj->IsExternalString()); 5613 DCHECK(obj->IsExternalString());
5576 isolate->heap()->external_string_table()->AddString(*obj); 5614 isolate->heap()->external_string_table()->AddString(*obj);
5577 } 5615 }
5578 return result; 5616 return result;
5579 } 5617 }
5580 5618
5581 5619
5582 Local<String> v8::String::NewExternal( 5620 Local<String> v8::String::NewExternal(
5583 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) { 5621 Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) {
5584 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5622 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5623 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()");
5585 LOG_API(i_isolate, "String::NewExternal"); 5624 LOG_API(i_isolate, "String::NewExternal");
5586 ENTER_V8(i_isolate); 5625 ENTER_V8(i_isolate);
5587 CHECK(resource && resource->data()); 5626 CHECK(resource && resource->data());
5588 i::Handle<i::String> result = 5627 i::Handle<i::String> result =
5589 NewExternalOneByteStringHandle(i_isolate, resource); 5628 NewExternalOneByteStringHandle(i_isolate, resource);
5590 i_isolate->heap()->external_string_table()->AddString(*result); 5629 i_isolate->heap()->external_string_table()->AddString(*result);
5591 return Utils::ToLocal(result); 5630 return Utils::ToLocal(result);
5592 } 5631 }
5593 5632
5594 5633
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5627 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; 5666 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false;
5628 int size = obj->Size(); // Byte size of the original string. 5667 int size = obj->Size(); // Byte size of the original string.
5629 if (size < i::ExternalString::kShortSize) return false; 5668 if (size < i::ExternalString::kShortSize) return false;
5630 i::StringShape shape(*obj); 5669 i::StringShape shape(*obj);
5631 return !shape.IsExternal(); 5670 return !shape.IsExternal();
5632 } 5671 }
5633 5672
5634 5673
5635 Local<v8::Object> v8::Object::New(Isolate* isolate) { 5674 Local<v8::Object> v8::Object::New(Isolate* isolate) {
5636 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5675 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5676 EnsureInitializedForIsolate(i_isolate, "v8::Object::New()");
5637 LOG_API(i_isolate, "Object::New"); 5677 LOG_API(i_isolate, "Object::New");
5638 ENTER_V8(i_isolate); 5678 ENTER_V8(i_isolate);
5639 i::Handle<i::JSObject> obj = 5679 i::Handle<i::JSObject> obj =
5640 i_isolate->factory()->NewJSObject(i_isolate->object_function()); 5680 i_isolate->factory()->NewJSObject(i_isolate->object_function());
5641 return Utils::ToLocal(obj); 5681 return Utils::ToLocal(obj);
5642 } 5682 }
5643 5683
5644 5684
5645 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) { 5685 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) {
5646 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5686 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5687 EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()");
5647 LOG_API(i_isolate, "NumberObject::New"); 5688 LOG_API(i_isolate, "NumberObject::New");
5648 ENTER_V8(i_isolate); 5689 ENTER_V8(i_isolate);
5649 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); 5690 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value);
5650 i::Handle<i::Object> obj = 5691 i::Handle<i::Object> obj =
5651 i::Object::ToObject(i_isolate, number).ToHandleChecked(); 5692 i::Object::ToObject(i_isolate, number).ToHandleChecked();
5652 return Utils::ToLocal(obj); 5693 return Utils::ToLocal(obj);
5653 } 5694 }
5654 5695
5655 5696
5656 double v8::NumberObject::ValueOf() const { 5697 double v8::NumberObject::ValueOf() const {
5657 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5698 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5658 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5699 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
5659 i::Isolate* isolate = jsvalue->GetIsolate(); 5700 i::Isolate* isolate = jsvalue->GetIsolate();
5660 LOG_API(isolate, "NumberObject::NumberValue"); 5701 LOG_API(isolate, "NumberObject::NumberValue");
5661 return jsvalue->value()->Number(); 5702 return jsvalue->value()->Number();
5662 } 5703 }
5663 5704
5664 5705
5665 Local<v8::Value> v8::BooleanObject::New(bool value) { 5706 Local<v8::Value> v8::BooleanObject::New(bool value) {
5666 i::Isolate* isolate = i::Isolate::Current(); 5707 i::Isolate* isolate = i::Isolate::Current();
5708 EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()");
5667 LOG_API(isolate, "BooleanObject::New"); 5709 LOG_API(isolate, "BooleanObject::New");
5668 ENTER_V8(isolate); 5710 ENTER_V8(isolate);
5669 i::Handle<i::Object> boolean(value 5711 i::Handle<i::Object> boolean(value
5670 ? isolate->heap()->true_value() 5712 ? isolate->heap()->true_value()
5671 : isolate->heap()->false_value(), 5713 : isolate->heap()->false_value(),
5672 isolate); 5714 isolate);
5673 i::Handle<i::Object> obj = 5715 i::Handle<i::Object> obj =
5674 i::Object::ToObject(isolate, boolean).ToHandleChecked(); 5716 i::Object::ToObject(isolate, boolean).ToHandleChecked();
5675 return Utils::ToLocal(obj); 5717 return Utils::ToLocal(obj);
5676 } 5718 }
5677 5719
5678 5720
5679 bool v8::BooleanObject::ValueOf() const { 5721 bool v8::BooleanObject::ValueOf() const {
5680 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5722 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5681 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5723 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
5682 i::Isolate* isolate = jsvalue->GetIsolate(); 5724 i::Isolate* isolate = jsvalue->GetIsolate();
5683 LOG_API(isolate, "BooleanObject::BooleanValue"); 5725 LOG_API(isolate, "BooleanObject::BooleanValue");
5684 return jsvalue->value()->IsTrue(); 5726 return jsvalue->value()->IsTrue();
5685 } 5727 }
5686 5728
5687 5729
5688 Local<v8::Value> v8::StringObject::New(Handle<String> value) { 5730 Local<v8::Value> v8::StringObject::New(Handle<String> value) {
5689 i::Handle<i::String> string = Utils::OpenHandle(*value); 5731 i::Handle<i::String> string = Utils::OpenHandle(*value);
5690 i::Isolate* isolate = string->GetIsolate(); 5732 i::Isolate* isolate = string->GetIsolate();
5733 EnsureInitializedForIsolate(isolate, "v8::StringObject::New()");
5691 LOG_API(isolate, "StringObject::New"); 5734 LOG_API(isolate, "StringObject::New");
5692 ENTER_V8(isolate); 5735 ENTER_V8(isolate);
5693 i::Handle<i::Object> obj = 5736 i::Handle<i::Object> obj =
5694 i::Object::ToObject(isolate, string).ToHandleChecked(); 5737 i::Object::ToObject(isolate, string).ToHandleChecked();
5695 return Utils::ToLocal(obj); 5738 return Utils::ToLocal(obj);
5696 } 5739 }
5697 5740
5698 5741
5699 Local<v8::String> v8::StringObject::ValueOf() const { 5742 Local<v8::String> v8::StringObject::ValueOf() const {
5700 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5743 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5701 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5744 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
5702 i::Isolate* isolate = jsvalue->GetIsolate(); 5745 i::Isolate* isolate = jsvalue->GetIsolate();
5703 LOG_API(isolate, "StringObject::StringValue"); 5746 LOG_API(isolate, "StringObject::StringValue");
5704 return Utils::ToLocal( 5747 return Utils::ToLocal(
5705 i::Handle<i::String>(i::String::cast(jsvalue->value()))); 5748 i::Handle<i::String>(i::String::cast(jsvalue->value())));
5706 } 5749 }
5707 5750
5708 5751
5709 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Handle<Symbol> value) { 5752 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Handle<Symbol> value) {
5710 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5753 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5754 EnsureInitializedForIsolate(i_isolate, "v8::SymbolObject::New()");
5711 LOG_API(i_isolate, "SymbolObject::New"); 5755 LOG_API(i_isolate, "SymbolObject::New");
5712 ENTER_V8(i_isolate); 5756 ENTER_V8(i_isolate);
5713 i::Handle<i::Object> obj = i::Object::ToObject( 5757 i::Handle<i::Object> obj = i::Object::ToObject(
5714 i_isolate, Utils::OpenHandle(*value)).ToHandleChecked(); 5758 i_isolate, Utils::OpenHandle(*value)).ToHandleChecked();
5715 return Utils::ToLocal(obj); 5759 return Utils::ToLocal(obj);
5716 } 5760 }
5717 5761
5718 5762
5719 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { 5763 Local<v8::Symbol> v8::SymbolObject::ValueOf() const {
5720 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5764 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5721 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5765 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
5722 i::Isolate* isolate = jsvalue->GetIsolate(); 5766 i::Isolate* isolate = jsvalue->GetIsolate();
5723 LOG_API(isolate, "SymbolObject::SymbolValue"); 5767 LOG_API(isolate, "SymbolObject::SymbolValue");
5724 return Utils::ToLocal( 5768 return Utils::ToLocal(
5725 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); 5769 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value())));
5726 } 5770 }
5727 5771
5728 5772
5729 Local<v8::Value> v8::Date::New(Isolate* isolate, double time) { 5773 Local<v8::Value> v8::Date::New(Isolate* isolate, double time) {
5730 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5774 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5775 EnsureInitializedForIsolate(i_isolate, "v8::Date::New()");
5731 LOG_API(i_isolate, "Date::New"); 5776 LOG_API(i_isolate, "Date::New");
5732 if (std::isnan(time)) { 5777 if (std::isnan(time)) {
5733 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 5778 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
5734 time = base::OS::nan_value(); 5779 time = base::OS::nan_value();
5735 } 5780 }
5736 ENTER_V8(i_isolate); 5781 ENTER_V8(i_isolate);
5737 EXCEPTION_PREAMBLE(i_isolate); 5782 EXCEPTION_PREAMBLE(i_isolate);
5738 i::Handle<i::Object> obj; 5783 i::Handle<i::Object> obj;
5739 has_pending_exception = !i::Execution::NewDate( 5784 has_pending_exception = !i::Execution::NewDate(
5740 i_isolate, time).ToHandle(&obj); 5785 i_isolate, time).ToHandle(&obj);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
5786 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; 5831 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i';
5787 DCHECK(num_flags <= static_cast<int>(arraysize(flags_buf))); 5832 DCHECK(num_flags <= static_cast<int>(arraysize(flags_buf)));
5788 return isolate->factory()->InternalizeOneByteString( 5833 return isolate->factory()->InternalizeOneByteString(
5789 i::Vector<const uint8_t>(flags_buf, num_flags)); 5834 i::Vector<const uint8_t>(flags_buf, num_flags));
5790 } 5835 }
5791 5836
5792 5837
5793 Local<v8::RegExp> v8::RegExp::New(Handle<String> pattern, 5838 Local<v8::RegExp> v8::RegExp::New(Handle<String> pattern,
5794 Flags flags) { 5839 Flags flags) {
5795 i::Isolate* isolate = Utils::OpenHandle(*pattern)->GetIsolate(); 5840 i::Isolate* isolate = Utils::OpenHandle(*pattern)->GetIsolate();
5841 EnsureInitializedForIsolate(isolate, "v8::RegExp::New()");
5796 LOG_API(isolate, "RegExp::New"); 5842 LOG_API(isolate, "RegExp::New");
5797 ENTER_V8(isolate); 5843 ENTER_V8(isolate);
5798 EXCEPTION_PREAMBLE(isolate); 5844 EXCEPTION_PREAMBLE(isolate);
5799 i::Handle<i::JSRegExp> obj; 5845 i::Handle<i::JSRegExp> obj;
5800 has_pending_exception = !i::Execution::NewJSRegExp( 5846 has_pending_exception = !i::Execution::NewJSRegExp(
5801 Utils::OpenHandle(*pattern), 5847 Utils::OpenHandle(*pattern),
5802 RegExpFlagsToString(flags)).ToHandle(&obj); 5848 RegExpFlagsToString(flags)).ToHandle(&obj);
5803 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::RegExp>()); 5849 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::RegExp>());
5804 return Utils::ToLocal(i::Handle<i::JSRegExp>::cast(obj)); 5850 return Utils::ToLocal(i::Handle<i::JSRegExp>::cast(obj));
5805 } 5851 }
(...skipping 16 matching lines...) Expand all
5822 #undef REGEXP_FLAG_ASSERT_EQ 5868 #undef REGEXP_FLAG_ASSERT_EQ
5823 5869
5824 v8::RegExp::Flags v8::RegExp::GetFlags() const { 5870 v8::RegExp::Flags v8::RegExp::GetFlags() const {
5825 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); 5871 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this);
5826 return static_cast<RegExp::Flags>(obj->GetFlags().value()); 5872 return static_cast<RegExp::Flags>(obj->GetFlags().value());
5827 } 5873 }
5828 5874
5829 5875
5830 Local<v8::Array> v8::Array::New(Isolate* isolate, int length) { 5876 Local<v8::Array> v8::Array::New(Isolate* isolate, int length) {
5831 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5877 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5878 EnsureInitializedForIsolate(i_isolate, "v8::Array::New()");
5832 LOG_API(i_isolate, "Array::New"); 5879 LOG_API(i_isolate, "Array::New");
5833 ENTER_V8(i_isolate); 5880 ENTER_V8(i_isolate);
5834 int real_length = length > 0 ? length : 0; 5881 int real_length = length > 0 ? length : 0;
5835 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); 5882 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length);
5836 i::Handle<i::Object> length_obj = 5883 i::Handle<i::Object> length_obj =
5837 i_isolate->factory()->NewNumberFromInt(real_length); 5884 i_isolate->factory()->NewNumberFromInt(real_length);
5838 obj->set_length(*length_obj); 5885 obj->set_length(*length_obj);
5839 return Utils::ToLocal(obj); 5886 return Utils::ToLocal(obj);
5840 } 5887 }
5841 5888
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
6041 6088
6042 6089
6043 size_t v8::ArrayBuffer::ByteLength() const { 6090 size_t v8::ArrayBuffer::ByteLength() const {
6044 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); 6091 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
6045 return static_cast<size_t>(obj->byte_length()->Number()); 6092 return static_cast<size_t>(obj->byte_length()->Number());
6046 } 6093 }
6047 6094
6048 6095
6049 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { 6096 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) {
6050 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6097 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6098 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(size_t)");
6051 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); 6099 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)");
6052 ENTER_V8(i_isolate); 6100 ENTER_V8(i_isolate);
6053 i::Handle<i::JSArrayBuffer> obj = 6101 i::Handle<i::JSArrayBuffer> obj =
6054 i_isolate->factory()->NewJSArrayBuffer(); 6102 i_isolate->factory()->NewJSArrayBuffer();
6055 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); 6103 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length);
6056 return Utils::ToLocal(obj); 6104 return Utils::ToLocal(obj);
6057 } 6105 }
6058 6106
6059 6107
6060 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, 6108 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data,
6061 size_t byte_length) { 6109 size_t byte_length) {
6062 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6110 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6111 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)");
6063 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); 6112 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)");
6064 ENTER_V8(i_isolate); 6113 ENTER_V8(i_isolate);
6065 i::Handle<i::JSArrayBuffer> obj = 6114 i::Handle<i::JSArrayBuffer> obj =
6066 i_isolate->factory()->NewJSArrayBuffer(); 6115 i_isolate->factory()->NewJSArrayBuffer();
6067 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); 6116 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length);
6068 return Utils::ToLocal(obj); 6117 return Utils::ToLocal(obj);
6069 } 6118 }
6070 6119
6071 6120
6072 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { 6121 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
6155 i::JSObject::GetElementsTransitionMap(obj, elements_kind); 6204 i::JSObject::GetElementsTransitionMap(obj, elements_kind);
6156 i::JSObject::SetMapAndElements(obj, map, elements); 6205 i::JSObject::SetMapAndElements(obj, map, elements);
6157 return obj; 6206 return obj;
6158 } 6207 }
6159 6208
6160 6209
6161 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \ 6210 #define TYPED_ARRAY_NEW(Type, type, TYPE, ctype, size) \
6162 Local<Type##Array> Type##Array::New(Handle<ArrayBuffer> array_buffer, \ 6211 Local<Type##Array> Type##Array::New(Handle<ArrayBuffer> array_buffer, \
6163 size_t byte_offset, size_t length) { \ 6212 size_t byte_offset, size_t length) { \
6164 i::Isolate* isolate = Utils::OpenHandle(*array_buffer)->GetIsolate(); \ 6213 i::Isolate* isolate = Utils::OpenHandle(*array_buffer)->GetIsolate(); \
6214 EnsureInitializedForIsolate(isolate, \
6215 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
6165 LOG_API(isolate, \ 6216 LOG_API(isolate, \
6166 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \ 6217 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)"); \
6167 ENTER_V8(isolate); \ 6218 ENTER_V8(isolate); \
6168 if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \ 6219 if (!Utils::ApiCheck(length <= static_cast<size_t>(i::Smi::kMaxValue), \
6169 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)", \ 6220 "v8::" #Type "Array::New(Handle<ArrayBuffer>, size_t, size_t)", \
6170 "length exceeds max allowed value")) { \ 6221 "length exceeds max allowed value")) { \
6171 return Local<Type##Array>(); \ 6222 return Local<Type##Array>(); \
6172 } \ 6223 } \
6173 i::Handle<i::JSTypedArray> obj = \ 6224 i::Handle<i::JSTypedArray> obj = \
6174 NewTypedArray<ctype, v8::kExternal##Type##Array, \ 6225 NewTypedArray<ctype, v8::kExternal##Type##Array, \
6175 i::EXTERNAL_##TYPE##_ELEMENTS>( \ 6226 i::EXTERNAL_##TYPE##_ELEMENTS>( \
6176 isolate, array_buffer, byte_offset, length); \ 6227 isolate, array_buffer, byte_offset, length); \
6177 return Utils::ToLocal##Type##Array(obj); \ 6228 return Utils::ToLocal##Type##Array(obj); \
6178 } 6229 }
6179 6230
6180 6231
6181 TYPED_ARRAYS(TYPED_ARRAY_NEW) 6232 TYPED_ARRAYS(TYPED_ARRAY_NEW)
6182 #undef TYPED_ARRAY_NEW 6233 #undef TYPED_ARRAY_NEW
6183 6234
6184 Local<DataView> DataView::New(Handle<ArrayBuffer> array_buffer, 6235 Local<DataView> DataView::New(Handle<ArrayBuffer> array_buffer,
6185 size_t byte_offset, size_t byte_length) { 6236 size_t byte_offset, size_t byte_length) {
6186 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer); 6237 i::Handle<i::JSArrayBuffer> buffer = Utils::OpenHandle(*array_buffer);
6187 i::Isolate* isolate = buffer->GetIsolate(); 6238 i::Isolate* isolate = buffer->GetIsolate();
6239 EnsureInitializedForIsolate(
6240 isolate, "v8::DataView::New(void*, size_t, size_t)");
6188 LOG_API(isolate, "v8::DataView::New(void*, size_t, size_t)"); 6241 LOG_API(isolate, "v8::DataView::New(void*, size_t, size_t)");
6189 ENTER_V8(isolate); 6242 ENTER_V8(isolate);
6190 i::Handle<i::JSDataView> obj = isolate->factory()->NewJSDataView(); 6243 i::Handle<i::JSDataView> obj = isolate->factory()->NewJSDataView();
6191 SetupArrayBufferView( 6244 SetupArrayBufferView(
6192 isolate, obj, buffer, byte_offset, byte_length); 6245 isolate, obj, buffer, byte_offset, byte_length);
6193 return Utils::ToLocal(obj); 6246 return Utils::ToLocal(obj);
6194 } 6247 }
6195 6248
6196 6249
6197 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) { 6250 Local<Symbol> v8::Symbol::New(Isolate* isolate, Local<String> name) {
6198 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6251 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6252 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()");
6199 LOG_API(i_isolate, "Symbol::New()"); 6253 LOG_API(i_isolate, "Symbol::New()");
6200 ENTER_V8(i_isolate); 6254 ENTER_V8(i_isolate);
6201 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); 6255 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
6202 if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name)); 6256 if (!name.IsEmpty()) result->set_name(*Utils::OpenHandle(*name));
6203 return Utils::ToLocal(result); 6257 return Utils::ToLocal(result);
6204 } 6258 }
6205 6259
6206 6260
6207 static i::Handle<i::Symbol> SymbolFor(i::Isolate* isolate, 6261 static i::Handle<i::Symbol> SymbolFor(i::Isolate* isolate,
6208 i::Handle<i::String> name, 6262 i::Handle<i::String> name,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
6253 } 6307 }
6254 6308
6255 6309
6256 Local<Symbol> v8::Symbol::GetUnscopables(Isolate* isolate) { 6310 Local<Symbol> v8::Symbol::GetUnscopables(Isolate* isolate) {
6257 return GetWellKnownSymbol(isolate, "Symbol.unscopables"); 6311 return GetWellKnownSymbol(isolate, "Symbol.unscopables");
6258 } 6312 }
6259 6313
6260 6314
6261 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { 6315 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
6262 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6316 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6317 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()");
6263 LOG_API(i_isolate, "Private::New()"); 6318 LOG_API(i_isolate, "Private::New()");
6264 ENTER_V8(i_isolate); 6319 ENTER_V8(i_isolate);
6265 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); 6320 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol();
6266 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); 6321 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name));
6267 Local<Symbol> result = Utils::ToLocal(symbol); 6322 Local<Symbol> result = Utils::ToLocal(symbol);
6268 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); 6323 return v8::Handle<Private>(reinterpret_cast<Private*>(*result));
6269 } 6324 }
6270 6325
6271 6326
6272 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) { 6327 Local<Private> v8::Private::ForApi(Isolate* isolate, Local<String> name) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
6324 return Integer::New(isolate, static_cast<int32_t>(value)); 6379 return Integer::New(isolate, static_cast<int32_t>(value));
6325 } 6380 }
6326 ENTER_V8(internal_isolate); 6381 ENTER_V8(internal_isolate);
6327 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); 6382 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
6328 return Utils::IntegerToLocal(result); 6383 return Utils::IntegerToLocal(result);
6329 } 6384 }
6330 6385
6331 6386
6332 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { 6387 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
6333 i::Isolate* isolate = i::Isolate::Current(); 6388 i::Isolate* isolate = i::Isolate::Current();
6389 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()");
6334 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); 6390 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false);
6335 ENTER_V8(isolate); 6391 ENTER_V8(isolate);
6336 i::HandleScope scope(isolate); 6392 i::HandleScope scope(isolate);
6337 NeanderArray listeners(isolate->factory()->message_listeners()); 6393 NeanderArray listeners(isolate->factory()->message_listeners());
6338 NeanderObject obj(isolate, 2); 6394 NeanderObject obj(isolate, 2);
6339 obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that))); 6395 obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that)));
6340 obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value() 6396 obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value()
6341 : *Utils::OpenHandle(*data)); 6397 : *Utils::OpenHandle(*data));
6342 listeners.add(obj.value()); 6398 listeners.add(obj.value());
6343 return true; 6399 return true;
6344 } 6400 }
6345 6401
6346 6402
6347 void V8::RemoveMessageListeners(MessageCallback that) { 6403 void V8::RemoveMessageListeners(MessageCallback that) {
6348 i::Isolate* isolate = i::Isolate::Current(); 6404 i::Isolate* isolate = i::Isolate::Current();
6405 EnsureInitializedForIsolate(isolate, "v8::V8::RemoveMessageListener()");
6349 ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return); 6406 ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return);
6350 ENTER_V8(isolate); 6407 ENTER_V8(isolate);
6351 i::HandleScope scope(isolate); 6408 i::HandleScope scope(isolate);
6352 NeanderArray listeners(isolate->factory()->message_listeners()); 6409 NeanderArray listeners(isolate->factory()->message_listeners());
6353 for (int i = 0; i < listeners.length(); i++) { 6410 for (int i = 0; i < listeners.length(); i++) {
6354 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones 6411 if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones
6355 6412
6356 NeanderObject listener(i::JSObject::cast(listeners.get(i))); 6413 NeanderObject listener(i::JSObject::cast(listeners.get(i)));
6357 i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listener.get(0))); 6414 i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listener.get(0)));
6358 if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) { 6415 if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
6611 if (params.entry_hook) { 6668 if (params.entry_hook) {
6612 isolate->set_function_entry_hook(params.entry_hook); 6669 isolate->set_function_entry_hook(params.entry_hook);
6613 } 6670 }
6614 if (params.code_event_handler) { 6671 if (params.code_event_handler) {
6615 isolate->InitializeLoggingAndCounters(); 6672 isolate->InitializeLoggingAndCounters();
6616 isolate->logger()->SetCodeEventHandler(kJitCodeEventDefault, 6673 isolate->logger()->SetCodeEventHandler(kJitCodeEventDefault,
6617 params.code_event_handler); 6674 params.code_event_handler);
6618 } 6675 }
6619 SetResourceConstraints(v8_isolate, 6676 SetResourceConstraints(v8_isolate,
6620 const_cast<ResourceConstraints*>(&params.constraints)); 6677 const_cast<ResourceConstraints*>(&params.constraints));
6621 if (params.enable_serializer) {
6622 isolate->enable_serializer();
6623 }
6624 // TODO(jochen): Once we got rid of Isolate::Current(), we can remove this.
6625 Isolate::Scope isolate_scope(v8_isolate);
6626 if (params.entry_hook || !i::Snapshot::Initialize(isolate)) {
6627 // If the isolate has a function entry hook, it needs to re-build all its
6628 // code stubs with entry hooks embedded, so don't deserialize a snapshot.
6629 isolate->Init(NULL);
6630 }
6631 return v8_isolate; 6678 return v8_isolate;
6632 } 6679 }
6633 6680
6634 6681
6635 void Isolate::Dispose() { 6682 void Isolate::Dispose() {
6636 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); 6683 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
6637 if (!Utils::ApiCheck(!isolate->IsInUse(), 6684 if (!Utils::ApiCheck(!isolate->IsInUse(),
6638 "v8::Isolate::Dispose()", 6685 "v8::Isolate::Dispose()",
6639 "Disposing the isolate that is entered by a thread.")) { 6686 "Disposing the isolate that is entered by a thread.")) {
6640 return; 6687 return;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
6923 DEFINE_ERROR(TypeError) 6970 DEFINE_ERROR(TypeError)
6924 DEFINE_ERROR(Error) 6971 DEFINE_ERROR(Error)
6925 6972
6926 #undef DEFINE_ERROR 6973 #undef DEFINE_ERROR
6927 6974
6928 6975
6929 // --- D e b u g S u p p o r t --- 6976 // --- D e b u g S u p p o r t ---
6930 6977
6931 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) { 6978 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) {
6932 i::Isolate* isolate = i::Isolate::Current(); 6979 i::Isolate* isolate = i::Isolate::Current();
6980 EnsureInitializedForIsolate(isolate, "v8::Debug::SetDebugEventListener()");
6933 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false); 6981 ON_BAILOUT(isolate, "v8::Debug::SetDebugEventListener()", return false);
6934 ENTER_V8(isolate); 6982 ENTER_V8(isolate);
6935 i::HandleScope scope(isolate); 6983 i::HandleScope scope(isolate);
6936 i::Handle<i::Object> foreign = isolate->factory()->undefined_value(); 6984 i::Handle<i::Object> foreign = isolate->factory()->undefined_value();
6937 if (that != NULL) { 6985 if (that != NULL) {
6938 foreign = isolate->factory()->NewForeign(FUNCTION_ADDR(that)); 6986 foreign = isolate->factory()->NewForeign(FUNCTION_ADDR(that));
6939 } 6987 }
6940 isolate->debug()->SetEventListener(foreign, 6988 isolate->debug()->SetEventListener(foreign,
6941 Utils::OpenHandle(*data, true)); 6989 Utils::OpenHandle(*data, true));
6942 return true; 6990 return true;
(...skipping 18 matching lines...) Expand all
6961 7009
6962 7010
6963 void Debug::DebugBreakForCommand(Isolate* isolate, ClientData* data) { 7011 void Debug::DebugBreakForCommand(Isolate* isolate, ClientData* data) {
6964 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 7012 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6965 internal_isolate->debug()->EnqueueDebugCommand(data); 7013 internal_isolate->debug()->EnqueueDebugCommand(data);
6966 } 7014 }
6967 7015
6968 7016
6969 void Debug::SetMessageHandler(v8::Debug::MessageHandler handler) { 7017 void Debug::SetMessageHandler(v8::Debug::MessageHandler handler) {
6970 i::Isolate* isolate = i::Isolate::Current(); 7018 i::Isolate* isolate = i::Isolate::Current();
7019 EnsureInitializedForIsolate(isolate, "v8::Debug::SetMessageHandler");
6971 ENTER_V8(isolate); 7020 ENTER_V8(isolate);
6972 isolate->debug()->SetMessageHandler(handler); 7021 isolate->debug()->SetMessageHandler(handler);
6973 } 7022 }
6974 7023
6975 7024
6976 void Debug::SendCommand(Isolate* isolate, 7025 void Debug::SendCommand(Isolate* isolate,
6977 const uint16_t* command, 7026 const uint16_t* command,
6978 int length, 7027 int length,
6979 ClientData* client_data) { 7028 ClientData* client_data) {
6980 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 7029 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
7034 } 7083 }
7035 7084
7036 7085
7037 void Debug::ProcessDebugMessages() { 7086 void Debug::ProcessDebugMessages() {
7038 i::Isolate::Current()->debug()->ProcessDebugMessages(true); 7087 i::Isolate::Current()->debug()->ProcessDebugMessages(true);
7039 } 7088 }
7040 7089
7041 7090
7042 Local<Context> Debug::GetDebugContext() { 7091 Local<Context> Debug::GetDebugContext() {
7043 i::Isolate* isolate = i::Isolate::Current(); 7092 i::Isolate* isolate = i::Isolate::Current();
7093 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()");
7044 ENTER_V8(isolate); 7094 ENTER_V8(isolate);
7045 return Utils::ToLocal(i::Isolate::Current()->debug()->GetDebugContext()); 7095 return Utils::ToLocal(i::Isolate::Current()->debug()->GetDebugContext());
7046 } 7096 }
7047 7097
7048 7098
7049 void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) { 7099 void Debug::SetLiveEditEnabled(Isolate* isolate, bool enable) {
7050 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 7100 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
7051 internal_isolate->debug()->set_live_edit_enabled(enable); 7101 internal_isolate->debug()->set_live_edit_enabled(enable);
7052 } 7102 }
7053 7103
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
7695 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7745 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7696 Address callback_address = 7746 Address callback_address =
7697 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7747 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7698 VMState<EXTERNAL> state(isolate); 7748 VMState<EXTERNAL> state(isolate);
7699 ExternalCallbackScope call_scope(isolate, callback_address); 7749 ExternalCallbackScope call_scope(isolate, callback_address);
7700 callback(info); 7750 callback(info);
7701 } 7751 }
7702 7752
7703 7753
7704 } } // namespace v8::internal 7754 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « samples/shell.cc ('k') | src/base/utils/random-number-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698