OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 } | 1071 } |
1072 obj->set_length(length); | 1072 obj->set_length(length); |
1073 obj->set_undetectable(false); | 1073 obj->set_undetectable(false); |
1074 obj->set_needs_access_check(false); | 1074 obj->set_needs_access_check(false); |
1075 if (!signature.IsEmpty()) | 1075 if (!signature.IsEmpty()) |
1076 obj->set_signature(*Utils::OpenHandle(*signature)); | 1076 obj->set_signature(*Utils::OpenHandle(*signature)); |
1077 return Utils::ToLocal(obj); | 1077 return Utils::ToLocal(obj); |
1078 } | 1078 } |
1079 | 1079 |
1080 Local<FunctionTemplate> FunctionTemplate::New( | 1080 Local<FunctionTemplate> FunctionTemplate::New( |
| 1081 Isolate* isolate, |
| 1082 FunctionCallback callback, |
| 1083 v8::Handle<Value> data, |
| 1084 v8::Handle<Signature> signature, |
| 1085 int length) { |
| 1086 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 1087 EnsureInitializedForIsolate(i_isolate, "v8::FunctionTemplate::New()"); |
| 1088 LOG_API(i_isolate, "FunctionTemplate::New"); |
| 1089 ENTER_V8(i_isolate); |
| 1090 return FunctionTemplateNew( |
| 1091 i_isolate, callback, data, signature, length, false); |
| 1092 } |
| 1093 |
| 1094 |
| 1095 Local<FunctionTemplate> FunctionTemplate::New( |
1081 FunctionCallback callback, | 1096 FunctionCallback callback, |
1082 v8::Handle<Value> data, | 1097 v8::Handle<Value> data, |
1083 v8::Handle<Signature> signature, | 1098 v8::Handle<Signature> signature, |
1084 int length) { | 1099 int length) { |
1085 i::Isolate* isolate = i::Isolate::Current(); | 1100 return New(Isolate::GetCurrent(), callback, data, signature, length); |
1086 EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()"); | |
1087 LOG_API(isolate, "FunctionTemplate::New"); | |
1088 ENTER_V8(isolate); | |
1089 return FunctionTemplateNew( | |
1090 isolate, callback, data, signature, length, false); | |
1091 } | 1101 } |
1092 | 1102 |
1093 | 1103 Local<Signature> Signature::New(Isolate* isolate, |
1094 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver, | 1104 Handle<FunctionTemplate> receiver, int argc, |
1095 int argc, Handle<FunctionTemplate> argv[]) { | 1105 Handle<FunctionTemplate> argv[]) { |
1096 i::Isolate* isolate = i::Isolate::Current(); | 1106 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
1097 EnsureInitializedForIsolate(isolate, "v8::Signature::New()"); | 1107 EnsureInitializedForIsolate(i_isolate, "v8::Signature::New()"); |
1098 LOG_API(isolate, "Signature::New"); | 1108 LOG_API(i_isolate, "Signature::New"); |
1099 ENTER_V8(isolate); | 1109 ENTER_V8(i_isolate); |
1100 i::Handle<i::Struct> struct_obj = | 1110 i::Handle<i::Struct> struct_obj = |
1101 isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE); | 1111 i_isolate->factory()->NewStruct(i::SIGNATURE_INFO_TYPE); |
1102 i::Handle<i::SignatureInfo> obj = | 1112 i::Handle<i::SignatureInfo> obj = |
1103 i::Handle<i::SignatureInfo>::cast(struct_obj); | 1113 i::Handle<i::SignatureInfo>::cast(struct_obj); |
1104 if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver)); | 1114 if (!receiver.IsEmpty()) obj->set_receiver(*Utils::OpenHandle(*receiver)); |
1105 if (argc > 0) { | 1115 if (argc > 0) { |
1106 i::Handle<i::FixedArray> args = isolate->factory()->NewFixedArray(argc); | 1116 i::Handle<i::FixedArray> args = i_isolate->factory()->NewFixedArray(argc); |
1107 for (int i = 0; i < argc; i++) { | 1117 for (int i = 0; i < argc; i++) { |
1108 if (!argv[i].IsEmpty()) | 1118 if (!argv[i].IsEmpty()) |
1109 args->set(i, *Utils::OpenHandle(*argv[i])); | 1119 args->set(i, *Utils::OpenHandle(*argv[i])); |
1110 } | 1120 } |
1111 obj->set_args(*args); | 1121 obj->set_args(*args); |
1112 } | 1122 } |
1113 return Utils::ToLocal(obj); | 1123 return Utils::ToLocal(obj); |
1114 } | 1124 } |
1115 | 1125 |
1116 | 1126 |
| 1127 Local<Signature> Signature::New(Handle<FunctionTemplate> receiver, |
| 1128 int argc, Handle<FunctionTemplate> argv[]) { |
| 1129 return New(Isolate::GetCurrent(), receiver, argc, argv); |
| 1130 } |
| 1131 |
| 1132 |
1117 Local<AccessorSignature> AccessorSignature::New( | 1133 Local<AccessorSignature> AccessorSignature::New( |
| 1134 Isolate* isolate, |
1118 Handle<FunctionTemplate> receiver) { | 1135 Handle<FunctionTemplate> receiver) { |
1119 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); | 1136 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); |
| 1137 } |
| 1138 |
| 1139 |
| 1140 // While this is just a cast, it's lame not to use an Isolate parameter. |
| 1141 Local<AccessorSignature> AccessorSignature::New( |
| 1142 Handle<FunctionTemplate> receiver) { |
| 1143 return Utils::AccessorSignatureToLocal(Utils::OpenHandle(*receiver)); |
1120 } | 1144 } |
1121 | 1145 |
1122 | 1146 |
1123 template<typename Operation> | 1147 template<typename Operation> |
1124 static Local<Operation> NewDescriptor( | 1148 static Local<Operation> NewDescriptor( |
1125 Isolate* isolate, | 1149 Isolate* isolate, |
1126 const i::DeclaredAccessorDescriptorData& data, | 1150 const i::DeclaredAccessorDescriptorData& data, |
1127 Data* previous_descriptor) { | 1151 Data* previous_descriptor) { |
1128 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 1152 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
1129 i::Handle<i::DeclaredAccessorDescriptor> previous = | 1153 i::Handle<i::DeclaredAccessorDescriptor> previous = |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 | 1380 |
1357 | 1381 |
1358 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { | 1382 Local<ObjectTemplate> FunctionTemplate::InstanceTemplate() { |
1359 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1383 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1360 if (EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this)) | 1384 if (EmptyCheck("v8::FunctionTemplate::InstanceTemplate()", this)) |
1361 return Local<ObjectTemplate>(); | 1385 return Local<ObjectTemplate>(); |
1362 ENTER_V8(isolate); | 1386 ENTER_V8(isolate); |
1363 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this); | 1387 i::Handle<i::FunctionTemplateInfo> handle = Utils::OpenHandle(this); |
1364 if (handle->instance_template()->IsUndefined()) { | 1388 if (handle->instance_template()->IsUndefined()) { |
1365 Local<ObjectTemplate> templ = | 1389 Local<ObjectTemplate> templ = |
1366 ObjectTemplate::New(ToApiHandle<FunctionTemplate>(handle)); | 1390 ObjectTemplate::New(isolate, ToApiHandle<FunctionTemplate>(handle)); |
1367 handle->set_instance_template(*Utils::OpenHandle(*templ)); | 1391 handle->set_instance_template(*Utils::OpenHandle(*templ)); |
1368 } | 1392 } |
1369 i::Handle<i::ObjectTemplateInfo> result( | 1393 i::Handle<i::ObjectTemplateInfo> result( |
1370 i::ObjectTemplateInfo::cast(handle->instance_template())); | 1394 i::ObjectTemplateInfo::cast(handle->instance_template())); |
1371 return Utils::ToLocal(result); | 1395 return Utils::ToLocal(result); |
1372 } | 1396 } |
1373 | 1397 |
1374 | 1398 |
1375 void FunctionTemplate::SetLength(int length) { | 1399 void FunctionTemplate::SetLength(int length) { |
1376 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1400 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
(...skipping 26 matching lines...) Expand all Loading... |
1403 void FunctionTemplate::RemovePrototype() { | 1427 void FunctionTemplate::RemovePrototype() { |
1404 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1428 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1405 ENTER_V8(isolate); | 1429 ENTER_V8(isolate); |
1406 Utils::OpenHandle(this)->set_remove_prototype(true); | 1430 Utils::OpenHandle(this)->set_remove_prototype(true); |
1407 } | 1431 } |
1408 | 1432 |
1409 | 1433 |
1410 // --- O b j e c t T e m p l a t e --- | 1434 // --- O b j e c t T e m p l a t e --- |
1411 | 1435 |
1412 | 1436 |
| 1437 Local<ObjectTemplate> ObjectTemplate::New(Isolate* isolate) { |
| 1438 return New(reinterpret_cast<i::Isolate*>(isolate), Local<FunctionTemplate>()); |
| 1439 } |
| 1440 |
| 1441 |
1413 Local<ObjectTemplate> ObjectTemplate::New() { | 1442 Local<ObjectTemplate> ObjectTemplate::New() { |
1414 return New(Local<FunctionTemplate>()); | 1443 return New(i::Isolate::Current(), Local<FunctionTemplate>()); |
1415 } | 1444 } |
1416 | 1445 |
1417 | 1446 |
1418 Local<ObjectTemplate> ObjectTemplate::New( | 1447 Local<ObjectTemplate> ObjectTemplate::New( |
| 1448 i::Isolate* isolate, |
1419 v8::Handle<FunctionTemplate> constructor) { | 1449 v8::Handle<FunctionTemplate> constructor) { |
1420 i::Isolate* isolate = i::Isolate::Current(); | |
1421 EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()"); | 1450 EnsureInitializedForIsolate(isolate, "v8::ObjectTemplate::New()"); |
1422 LOG_API(isolate, "ObjectTemplate::New"); | 1451 LOG_API(isolate, "ObjectTemplate::New"); |
1423 ENTER_V8(isolate); | 1452 ENTER_V8(isolate); |
1424 i::Handle<i::Struct> struct_obj = | 1453 i::Handle<i::Struct> struct_obj = |
1425 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); | 1454 isolate->factory()->NewStruct(i::OBJECT_TEMPLATE_INFO_TYPE); |
1426 i::Handle<i::ObjectTemplateInfo> obj = | 1455 i::Handle<i::ObjectTemplateInfo> obj = |
1427 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); | 1456 i::Handle<i::ObjectTemplateInfo>::cast(struct_obj); |
1428 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); | 1457 InitializeTemplate(obj, Consts::OBJECT_TEMPLATE); |
1429 if (!constructor.IsEmpty()) | 1458 if (!constructor.IsEmpty()) |
1430 obj->set_constructor(*Utils::OpenHandle(*constructor)); | 1459 obj->set_constructor(*Utils::OpenHandle(*constructor)); |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2278 &has_pending_exception); | 2307 &has_pending_exception); |
2279 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::String>()); | 2308 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::String>()); |
2280 if (result->IsString()) { | 2309 if (result->IsString()) { |
2281 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result))); | 2310 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result))); |
2282 } else { | 2311 } else { |
2283 return Local<String>(); | 2312 return Local<String>(); |
2284 } | 2313 } |
2285 } | 2314 } |
2286 | 2315 |
2287 | 2316 |
| 2317 void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) { |
| 2318 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 2319 ENTER_V8(i_isolate); |
| 2320 i_isolate->PrintCurrentStackTrace(out); |
| 2321 } |
| 2322 |
| 2323 |
2288 void Message::PrintCurrentStackTrace(FILE* out) { | 2324 void Message::PrintCurrentStackTrace(FILE* out) { |
2289 i::Isolate* isolate = i::Isolate::Current(); | 2325 PrintCurrentStackTrace(Isolate::GetCurrent(), out); |
2290 ENTER_V8(isolate); | |
2291 isolate->PrintCurrentStackTrace(out); | |
2292 } | 2326 } |
2293 | 2327 |
2294 | 2328 |
2295 // --- S t a c k T r a c e --- | 2329 // --- S t a c k T r a c e --- |
2296 | 2330 |
2297 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { | 2331 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { |
2298 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2332 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2299 ENTER_V8(isolate); | 2333 ENTER_V8(isolate); |
2300 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2334 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2301 i::Handle<i::JSArray> self = Utils::OpenHandle(this); | 2335 i::Handle<i::JSArray> self = Utils::OpenHandle(this); |
(...skipping 10 matching lines...) Expand all Loading... |
2312 } | 2346 } |
2313 | 2347 |
2314 | 2348 |
2315 Local<Array> StackTrace::AsArray() { | 2349 Local<Array> StackTrace::AsArray() { |
2316 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2350 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2317 ENTER_V8(isolate); | 2351 ENTER_V8(isolate); |
2318 return Utils::ToLocal(Utils::OpenHandle(this)); | 2352 return Utils::ToLocal(Utils::OpenHandle(this)); |
2319 } | 2353 } |
2320 | 2354 |
2321 | 2355 |
| 2356 Local<StackTrace> StackTrace::CurrentStackTrace( |
| 2357 Isolate* isolate, |
| 2358 int frame_limit, |
| 2359 StackTraceOptions options) { |
| 2360 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 2361 ENTER_V8(i_isolate); |
| 2362 i::Handle<i::JSArray> stackTrace = |
| 2363 i_isolate->CaptureCurrentStackTrace(frame_limit, options); |
| 2364 return Utils::StackTraceToLocal(stackTrace); |
| 2365 } |
| 2366 |
| 2367 |
2322 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit, | 2368 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit, |
2323 StackTraceOptions options) { | 2369 StackTraceOptions options) { |
2324 i::Isolate* isolate = i::Isolate::Current(); | 2370 return CurrentStackTrace(Isolate::GetCurrent(), frame_limit, options); |
2325 ENTER_V8(isolate); | |
2326 i::Handle<i::JSArray> stackTrace = | |
2327 isolate->CaptureCurrentStackTrace(frame_limit, options); | |
2328 return Utils::StackTraceToLocal(stackTrace); | |
2329 } | 2371 } |
2330 | 2372 |
2331 | 2373 |
2332 // --- S t a c k F r a m e --- | 2374 // --- S t a c k F r a m e --- |
2333 | 2375 |
2334 int StackFrame::GetLineNumber() const { | 2376 int StackFrame::GetLineNumber() const { |
2335 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2377 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2336 ENTER_V8(isolate); | 2378 ENTER_V8(isolate); |
2337 i::HandleScope scope(isolate); | 2379 i::HandleScope scope(isolate); |
2338 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2380 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
(...skipping 3300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5639 ASSERT(parent->IsSlicedString()); | 5681 ASSERT(parent->IsSlicedString()); |
5640 i::Handle<i::SlicedString> slice = i::Handle<i::SlicedString>::cast(parent); | 5682 i::Handle<i::SlicedString> slice = i::Handle<i::SlicedString>::cast(parent); |
5641 slice->set_parent(*external); | 5683 slice->set_parent(*external); |
5642 slice->set_offset(0); | 5684 slice->set_offset(0); |
5643 } | 5685 } |
5644 return true; | 5686 return true; |
5645 } | 5687 } |
5646 | 5688 |
5647 | 5689 |
5648 Local<String> v8::String::NewExternal( | 5690 Local<String> v8::String::NewExternal( |
| 5691 Isolate* isolate, |
| 5692 v8::String::ExternalStringResource* resource) { |
| 5693 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5694 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); |
| 5695 LOG_API(i_isolate, "String::NewExternal"); |
| 5696 ENTER_V8(i_isolate); |
| 5697 CHECK(resource && resource->data()); |
| 5698 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); |
| 5699 i_isolate->heap()->external_string_table()->AddString(*result); |
| 5700 return Utils::ToLocal(result); |
| 5701 } |
| 5702 |
| 5703 |
| 5704 Local<String> v8::String::NewExternal( |
5649 v8::String::ExternalStringResource* resource) { | 5705 v8::String::ExternalStringResource* resource) { |
5650 i::Isolate* isolate = i::Isolate::Current(); | 5706 return NewExternal(Isolate::GetCurrent(), resource); |
5651 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); | |
5652 LOG_API(isolate, "String::NewExternal"); | |
5653 ENTER_V8(isolate); | |
5654 CHECK(resource && resource->data()); | |
5655 i::Handle<i::String> result = NewExternalStringHandle(isolate, resource); | |
5656 isolate->heap()->external_string_table()->AddString(*result); | |
5657 return Utils::ToLocal(result); | |
5658 } | 5707 } |
5659 | 5708 |
5660 | 5709 |
5661 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { | 5710 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { |
5662 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5711 i::Handle<i::String> obj = Utils::OpenHandle(this); |
5663 i::Isolate* isolate = obj->GetIsolate(); | 5712 i::Isolate* isolate = obj->GetIsolate(); |
5664 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5713 if (i::StringShape(*obj).IsExternalTwoByte()) { |
5665 return false; // Already an external string. | 5714 return false; // Already an external string. |
5666 } | 5715 } |
5667 ENTER_V8(isolate); | 5716 ENTER_V8(isolate); |
(...skipping 20 matching lines...) Expand all Loading... |
5688 | 5737 |
5689 ASSERT(external->IsExternalString()); | 5738 ASSERT(external->IsExternalString()); |
5690 if (result && !external->IsInternalizedString()) { | 5739 if (result && !external->IsInternalizedString()) { |
5691 isolate->heap()->external_string_table()->AddString(*external); | 5740 isolate->heap()->external_string_table()->AddString(*external); |
5692 } | 5741 } |
5693 return result; | 5742 return result; |
5694 } | 5743 } |
5695 | 5744 |
5696 | 5745 |
5697 Local<String> v8::String::NewExternal( | 5746 Local<String> v8::String::NewExternal( |
| 5747 Isolate* isolate, |
| 5748 v8::String::ExternalAsciiStringResource* resource) { |
| 5749 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5750 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); |
| 5751 LOG_API(i_isolate, "String::NewExternal"); |
| 5752 ENTER_V8(i_isolate); |
| 5753 CHECK(resource && resource->data()); |
| 5754 i::Handle<i::String> result = |
| 5755 NewExternalAsciiStringHandle(i_isolate, resource); |
| 5756 i_isolate->heap()->external_string_table()->AddString(*result); |
| 5757 return Utils::ToLocal(result); |
| 5758 } |
| 5759 |
| 5760 |
| 5761 Local<String> v8::String::NewExternal( |
5698 v8::String::ExternalAsciiStringResource* resource) { | 5762 v8::String::ExternalAsciiStringResource* resource) { |
5699 i::Isolate* isolate = i::Isolate::Current(); | 5763 return NewExternal(Isolate::GetCurrent(), resource); |
5700 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); | |
5701 LOG_API(isolate, "String::NewExternal"); | |
5702 ENTER_V8(isolate); | |
5703 CHECK(resource && resource->data()); | |
5704 i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource); | |
5705 isolate->heap()->external_string_table()->AddString(*result); | |
5706 return Utils::ToLocal(result); | |
5707 } | 5764 } |
5708 | 5765 |
5709 | 5766 |
5710 bool v8::String::MakeExternal( | 5767 bool v8::String::MakeExternal( |
5711 v8::String::ExternalAsciiStringResource* resource) { | 5768 v8::String::ExternalAsciiStringResource* resource) { |
5712 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5769 i::Handle<i::String> obj = Utils::OpenHandle(this); |
5713 i::Isolate* isolate = obj->GetIsolate(); | 5770 i::Isolate* isolate = obj->GetIsolate(); |
5714 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5771 if (i::StringShape(*obj).IsExternalTwoByte()) { |
5715 return false; // Already an external string. | 5772 return false; // Already an external string. |
5716 } | 5773 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5755 if (isolate->heap()->old_pointer_space()->Contains(*obj)) return false; | 5812 if (isolate->heap()->old_pointer_space()->Contains(*obj)) return false; |
5756 | 5813 |
5757 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; | 5814 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; |
5758 int size = obj->Size(); // Byte size of the original string. | 5815 int size = obj->Size(); // Byte size of the original string. |
5759 if (size < i::ExternalString::kShortSize) return false; | 5816 if (size < i::ExternalString::kShortSize) return false; |
5760 i::StringShape shape(*obj); | 5817 i::StringShape shape(*obj); |
5761 return !shape.IsExternal(); | 5818 return !shape.IsExternal(); |
5762 } | 5819 } |
5763 | 5820 |
5764 | 5821 |
| 5822 Local<v8::Object> v8::Object::New(Isolate* isolate) { |
| 5823 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5824 EnsureInitializedForIsolate(i_isolate, "v8::Object::New()"); |
| 5825 LOG_API(i_isolate, "Object::New"); |
| 5826 ENTER_V8(i_isolate); |
| 5827 i::Handle<i::JSObject> obj = |
| 5828 i_isolate->factory()->NewJSObject(i_isolate->object_function()); |
| 5829 return Utils::ToLocal(obj); |
| 5830 } |
| 5831 |
| 5832 |
5765 Local<v8::Object> v8::Object::New() { | 5833 Local<v8::Object> v8::Object::New() { |
5766 i::Isolate* isolate = i::Isolate::Current(); | 5834 return New(Isolate::GetCurrent()); |
5767 EnsureInitializedForIsolate(isolate, "v8::Object::New()"); | 5835 } |
5768 LOG_API(isolate, "Object::New"); | 5836 |
5769 ENTER_V8(isolate); | 5837 |
5770 i::Handle<i::JSObject> obj = | 5838 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) { |
5771 isolate->factory()->NewJSObject(isolate->object_function()); | 5839 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5840 EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()"); |
| 5841 LOG_API(i_isolate, "NumberObject::New"); |
| 5842 ENTER_V8(i_isolate); |
| 5843 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); |
| 5844 i::Handle<i::Object> obj = i_isolate->factory()->ToObject(number); |
5772 return Utils::ToLocal(obj); | 5845 return Utils::ToLocal(obj); |
5773 } | 5846 } |
5774 | 5847 |
5775 | 5848 |
5776 Local<v8::Value> v8::NumberObject::New(double value) { | 5849 Local<v8::Value> v8::NumberObject::New(double value) { |
5777 i::Isolate* isolate = i::Isolate::Current(); | 5850 return New(Isolate::GetCurrent(), value); |
5778 EnsureInitializedForIsolate(isolate, "v8::NumberObject::New()"); | |
5779 LOG_API(isolate, "NumberObject::New"); | |
5780 ENTER_V8(isolate); | |
5781 i::Handle<i::Object> number = isolate->factory()->NewNumber(value); | |
5782 i::Handle<i::Object> obj = isolate->factory()->ToObject(number); | |
5783 return Utils::ToLocal(obj); | |
5784 } | 5851 } |
5785 | 5852 |
5786 | 5853 |
5787 double v8::NumberObject::ValueOf() const { | 5854 double v8::NumberObject::ValueOf() const { |
5788 i::Isolate* isolate = i::Isolate::Current(); | 5855 i::Isolate* isolate = i::Isolate::Current(); |
5789 LOG_API(isolate, "NumberObject::NumberValue"); | 5856 LOG_API(isolate, "NumberObject::NumberValue"); |
5790 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5857 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5791 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5858 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
5792 return jsvalue->value()->Number(); | 5859 return jsvalue->value()->Number(); |
5793 } | 5860 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5851 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { | 5918 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { |
5852 i::Isolate* isolate = i::Isolate::Current(); | 5919 i::Isolate* isolate = i::Isolate::Current(); |
5853 LOG_API(isolate, "SymbolObject::SymbolValue"); | 5920 LOG_API(isolate, "SymbolObject::SymbolValue"); |
5854 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5921 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5855 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5922 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
5856 return Utils::ToLocal( | 5923 return Utils::ToLocal( |
5857 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); | 5924 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); |
5858 } | 5925 } |
5859 | 5926 |
5860 | 5927 |
| 5928 Local<v8::Value> v8::Date::New(Isolate* isolate, double time) { |
| 5929 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5930 EnsureInitializedForIsolate(i_isolate, "v8::Date::New()"); |
| 5931 LOG_API(i_isolate, "Date::New"); |
| 5932 if (std::isnan(time)) { |
| 5933 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. |
| 5934 time = i::OS::nan_value(); |
| 5935 } |
| 5936 ENTER_V8(i_isolate); |
| 5937 EXCEPTION_PREAMBLE(i_isolate); |
| 5938 i::Handle<i::Object> obj = |
| 5939 i::Execution::NewDate(i_isolate, time, &has_pending_exception); |
| 5940 EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>()); |
| 5941 return Utils::ToLocal(obj); |
| 5942 } |
| 5943 |
| 5944 |
5861 Local<v8::Value> v8::Date::New(double time) { | 5945 Local<v8::Value> v8::Date::New(double time) { |
5862 i::Isolate* isolate = i::Isolate::Current(); | 5946 return New(Isolate::GetCurrent(), time); |
5863 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); | |
5864 LOG_API(isolate, "Date::New"); | |
5865 if (std::isnan(time)) { | |
5866 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | |
5867 time = i::OS::nan_value(); | |
5868 } | |
5869 ENTER_V8(isolate); | |
5870 EXCEPTION_PREAMBLE(isolate); | |
5871 i::Handle<i::Object> obj = | |
5872 i::Execution::NewDate(isolate, time, &has_pending_exception); | |
5873 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Value>()); | |
5874 return Utils::ToLocal(obj); | |
5875 } | 5947 } |
5876 | 5948 |
5877 | 5949 |
5878 double v8::Date::ValueOf() const { | 5950 double v8::Date::ValueOf() const { |
5879 i::Isolate* isolate = i::Isolate::Current(); | 5951 i::Isolate* isolate = i::Isolate::Current(); |
5880 LOG_API(isolate, "Date::NumberValue"); | 5952 LOG_API(isolate, "Date::NumberValue"); |
5881 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5953 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
5882 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); | 5954 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); |
5883 return jsdate->value()->Number(); | 5955 return jsdate->value()->Number(); |
5884 } | 5956 } |
5885 | 5957 |
5886 | 5958 |
5887 void v8::Date::DateTimeConfigurationChangeNotification() { | 5959 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { |
5888 i::Isolate* isolate = i::Isolate::Current(); | 5960 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
5889 ON_BAILOUT(isolate, "v8::Date::DateTimeConfigurationChangeNotification()", | 5961 ON_BAILOUT(i_isolate, "v8::Date::DateTimeConfigurationChangeNotification()", |
5890 return); | 5962 return); |
5891 LOG_API(isolate, "Date::DateTimeConfigurationChangeNotification"); | 5963 LOG_API(i_isolate, "Date::DateTimeConfigurationChangeNotification"); |
5892 ENTER_V8(isolate); | 5964 ENTER_V8(i_isolate); |
5893 | 5965 |
5894 isolate->date_cache()->ResetDateCache(); | 5966 i_isolate->date_cache()->ResetDateCache(); |
5895 | 5967 |
5896 i::HandleScope scope(isolate); | 5968 i::HandleScope scope(i_isolate); |
5897 // Get the function ResetDateCache (defined in date.js). | 5969 // Get the function ResetDateCache (defined in date.js). |
5898 i::Handle<i::String> func_name_str = | 5970 i::Handle<i::String> func_name_str = |
5899 isolate->factory()->InternalizeOneByteString( | 5971 i_isolate->factory()->InternalizeOneByteString( |
5900 STATIC_ASCII_VECTOR("ResetDateCache")); | 5972 STATIC_ASCII_VECTOR("ResetDateCache")); |
5901 i::MaybeObject* result = | 5973 i::MaybeObject* result = |
5902 isolate->js_builtins_object()->GetProperty(*func_name_str); | 5974 i_isolate->js_builtins_object()->GetProperty(*func_name_str); |
5903 i::Object* object_func; | 5975 i::Object* object_func; |
5904 if (!result->ToObject(&object_func)) { | 5976 if (!result->ToObject(&object_func)) { |
5905 return; | 5977 return; |
5906 } | 5978 } |
5907 | 5979 |
5908 if (object_func->IsJSFunction()) { | 5980 if (object_func->IsJSFunction()) { |
5909 i::Handle<i::JSFunction> func = | 5981 i::Handle<i::JSFunction> func = |
5910 i::Handle<i::JSFunction>(i::JSFunction::cast(object_func)); | 5982 i::Handle<i::JSFunction>(i::JSFunction::cast(object_func)); |
5911 | 5983 |
5912 // Call ResetDateCache(0 but expect no exceptions: | 5984 // Call ResetDateCache(0 but expect no exceptions: |
5913 bool caught_exception = false; | 5985 bool caught_exception = false; |
5914 i::Execution::TryCall(func, | 5986 i::Execution::TryCall(func, |
5915 isolate->js_builtins_object(), | 5987 i_isolate->js_builtins_object(), |
5916 0, | 5988 0, |
5917 NULL, | 5989 NULL, |
5918 &caught_exception); | 5990 &caught_exception); |
5919 } | 5991 } |
5920 } | 5992 } |
5921 | 5993 |
5922 | 5994 |
| 5995 void v8::Date::DateTimeConfigurationChangeNotification() { |
| 5996 DateTimeConfigurationChangeNotification(Isolate::GetCurrent()); |
| 5997 } |
| 5998 |
| 5999 |
5923 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { | 6000 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { |
5924 i::Isolate* isolate = i::Isolate::Current(); | 6001 i::Isolate* isolate = i::Isolate::Current(); |
5925 uint8_t flags_buf[3]; | 6002 uint8_t flags_buf[3]; |
5926 int num_flags = 0; | 6003 int num_flags = 0; |
5927 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; | 6004 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; |
5928 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; | 6005 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; |
5929 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; | 6006 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; |
5930 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); | 6007 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); |
5931 return isolate->factory()->InternalizeOneByteString( | 6008 return isolate->factory()->InternalizeOneByteString( |
5932 i::Vector<const uint8_t>(flags_buf, num_flags)); | 6009 i::Vector<const uint8_t>(flags_buf, num_flags)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5964 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE); | 6041 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE); |
5965 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE); | 6042 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE); |
5966 #undef REGEXP_FLAG_ASSERT_EQ | 6043 #undef REGEXP_FLAG_ASSERT_EQ |
5967 | 6044 |
5968 v8::RegExp::Flags v8::RegExp::GetFlags() const { | 6045 v8::RegExp::Flags v8::RegExp::GetFlags() const { |
5969 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); | 6046 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); |
5970 return static_cast<RegExp::Flags>(obj->GetFlags().value()); | 6047 return static_cast<RegExp::Flags>(obj->GetFlags().value()); |
5971 } | 6048 } |
5972 | 6049 |
5973 | 6050 |
| 6051 Local<v8::Array> v8::Array::New(Isolate* isolate, int length) { |
| 6052 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6053 EnsureInitializedForIsolate(i_isolate, "v8::Array::New()"); |
| 6054 LOG_API(i_isolate, "Array::New"); |
| 6055 ENTER_V8(i_isolate); |
| 6056 int real_length = length > 0 ? length : 0; |
| 6057 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); |
| 6058 i::Handle<i::Object> length_obj = |
| 6059 i_isolate->factory()->NewNumberFromInt(real_length); |
| 6060 obj->set_length(*length_obj); |
| 6061 return Utils::ToLocal(obj); |
| 6062 } |
| 6063 |
| 6064 |
5974 Local<v8::Array> v8::Array::New(int length) { | 6065 Local<v8::Array> v8::Array::New(int length) { |
5975 i::Isolate* isolate = i::Isolate::Current(); | 6066 return New(Isolate::GetCurrent(), length); |
5976 EnsureInitializedForIsolate(isolate, "v8::Array::New()"); | |
5977 LOG_API(isolate, "Array::New"); | |
5978 ENTER_V8(isolate); | |
5979 int real_length = length > 0 ? length : 0; | |
5980 i::Handle<i::JSArray> obj = isolate->factory()->NewJSArray(real_length); | |
5981 i::Handle<i::Object> length_obj = | |
5982 isolate->factory()->NewNumberFromInt(real_length); | |
5983 obj->set_length(*length_obj); | |
5984 return Utils::ToLocal(obj); | |
5985 } | 6067 } |
5986 | 6068 |
5987 | 6069 |
5988 uint32_t v8::Array::Length() const { | 6070 uint32_t v8::Array::Length() const { |
5989 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); | 6071 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); |
5990 i::Object* length = obj->length(); | 6072 i::Object* length = obj->length(); |
5991 if (length->IsSmi()) { | 6073 if (length->IsSmi()) { |
5992 return i::Smi::cast(length)->value(); | 6074 return i::Smi::cast(length)->value(); |
5993 } else { | 6075 } else { |
5994 return static_cast<uint32_t>(length->Number()); | 6076 return static_cast<uint32_t>(length->Number()); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6061 obj->Neuter(); | 6143 obj->Neuter(); |
6062 } | 6144 } |
6063 | 6145 |
6064 | 6146 |
6065 size_t v8::ArrayBuffer::ByteLength() const { | 6147 size_t v8::ArrayBuffer::ByteLength() const { |
6066 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 6148 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
6067 return static_cast<size_t>(obj->byte_length()->Number()); | 6149 return static_cast<size_t>(obj->byte_length()->Number()); |
6068 } | 6150 } |
6069 | 6151 |
6070 | 6152 |
| 6153 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { |
| 6154 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6155 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(size_t)"); |
| 6156 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); |
| 6157 ENTER_V8(i_isolate); |
| 6158 i::Handle<i::JSArrayBuffer> obj = |
| 6159 i_isolate->factory()->NewJSArrayBuffer(); |
| 6160 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); |
| 6161 return Utils::ToLocal(obj); |
| 6162 } |
| 6163 |
| 6164 |
6071 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) { | 6165 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) { |
6072 i::Isolate* isolate = i::Isolate::Current(); | 6166 return New(Isolate::GetCurrent(), byte_length); |
6073 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(size_t)"); | 6167 } |
6074 LOG_API(isolate, "v8::ArrayBuffer::New(size_t)"); | 6168 |
6075 ENTER_V8(isolate); | 6169 |
| 6170 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, |
| 6171 size_t byte_length) { |
| 6172 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6173 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
| 6174 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
| 6175 ENTER_V8(i_isolate); |
6076 i::Handle<i::JSArrayBuffer> obj = | 6176 i::Handle<i::JSArrayBuffer> obj = |
6077 isolate->factory()->NewJSArrayBuffer(); | 6177 i_isolate->factory()->NewJSArrayBuffer(); |
6078 i::Runtime::SetupArrayBufferAllocatingData(isolate, obj, byte_length); | 6178 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); |
6079 return Utils::ToLocal(obj); | 6179 return Utils::ToLocal(obj); |
6080 } | 6180 } |
6081 | 6181 |
6082 | 6182 |
6083 Local<ArrayBuffer> v8::ArrayBuffer::New(void* data, size_t byte_length) { | 6183 Local<ArrayBuffer> v8::ArrayBuffer::New(void* data, size_t byte_length) { |
6084 i::Isolate* isolate = i::Isolate::Current(); | 6184 return New(Isolate::GetCurrent(), data, byte_length); |
6085 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(void*, size_t)"); | |
6086 LOG_API(isolate, "v8::ArrayBuffer::New(void*, size_t)"); | |
6087 ENTER_V8(isolate); | |
6088 i::Handle<i::JSArrayBuffer> obj = | |
6089 isolate->factory()->NewJSArrayBuffer(); | |
6090 i::Runtime::SetupArrayBuffer(isolate, obj, true, data, byte_length); | |
6091 return Utils::ToLocal(obj); | |
6092 } | 6185 } |
6093 | 6186 |
6094 | 6187 |
6095 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { | 6188 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { |
6096 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 6189 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
6097 ASSERT(obj->buffer()->IsJSArrayBuffer()); | 6190 ASSERT(obj->buffer()->IsJSArrayBuffer()); |
6098 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); | 6191 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); |
6099 return Utils::ToLocal(buffer); | 6192 return Utils::ToLocal(buffer); |
6100 } | 6193 } |
6101 | 6194 |
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7678 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7771 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7679 Address callback_address = | 7772 Address callback_address = |
7680 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7773 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7681 VMState<EXTERNAL> state(isolate); | 7774 VMState<EXTERNAL> state(isolate); |
7682 ExternalCallbackScope call_scope(isolate, callback_address); | 7775 ExternalCallbackScope call_scope(isolate, callback_address); |
7683 callback(info); | 7776 callback(info); |
7684 } | 7777 } |
7685 | 7778 |
7686 | 7779 |
7687 } } // namespace v8::internal | 7780 } } // namespace v8::internal |
OLD | NEW |