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

Side by Side Diff: src/api.cc

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