| 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 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3394 // to never change the result of the basic enumeration function so | 3436 // to never change the result of the basic enumeration function so |
| 3395 // we clone the result. | 3437 // we clone the result. |
| 3396 i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value); | 3438 i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value); |
| 3397 i::Handle<i::JSArray> result = | 3439 i::Handle<i::JSArray> result = |
| 3398 isolate->factory()->NewJSArrayWithElements(elms); | 3440 isolate->factory()->NewJSArrayWithElements(elms); |
| 3399 return Utils::ToLocal(scope.CloseAndEscape(result)); | 3441 return Utils::ToLocal(scope.CloseAndEscape(result)); |
| 3400 } | 3442 } |
| 3401 | 3443 |
| 3402 | 3444 |
| 3403 Local<String> v8::Object::ObjectProtoToString() { | 3445 Local<String> v8::Object::ObjectProtoToString() { |
| 3404 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3446 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3405 ON_BAILOUT(isolate, "v8::Object::ObjectProtoToString()", | 3447 Isolate* isolate = reinterpret_cast<Isolate*>(i_isolate); |
| 3448 ON_BAILOUT(i_isolate, "v8::Object::ObjectProtoToString()", |
| 3406 return Local<v8::String>()); | 3449 return Local<v8::String>()); |
| 3407 ENTER_V8(isolate); | 3450 ENTER_V8(i_isolate); |
| 3408 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3451 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 3409 | 3452 |
| 3410 i::Handle<i::Object> name(self->class_name(), isolate); | 3453 i::Handle<i::Object> name(self->class_name(), i_isolate); |
| 3411 | 3454 |
| 3412 // Native implementation of Object.prototype.toString (v8natives.js): | 3455 // Native implementation of Object.prototype.toString (v8natives.js): |
| 3413 // var c = %_ClassOf(this); | 3456 // var c = %_ClassOf(this); |
| 3414 // if (c === 'Arguments') c = 'Object'; | 3457 // if (c === 'Arguments') c = 'Object'; |
| 3415 // return "[object " + c + "]"; | 3458 // return "[object " + c + "]"; |
| 3416 | 3459 |
| 3417 if (!name->IsString()) { | 3460 if (!name->IsString()) { |
| 3418 return v8::String::New("[object ]"); | 3461 return v8::String::NewFromUtf8(isolate, "[object ]"); |
| 3419 | |
| 3420 } else { | 3462 } else { |
| 3421 i::Handle<i::String> class_name = i::Handle<i::String>::cast(name); | 3463 i::Handle<i::String> class_name = i::Handle<i::String>::cast(name); |
| 3422 if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Arguments"))) { | 3464 if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Arguments"))) { |
| 3423 return v8::String::New("[object Object]"); | 3465 return v8::String::NewFromUtf8(isolate, "[object Object]"); |
| 3424 | |
| 3425 } else { | 3466 } else { |
| 3426 const char* prefix = "[object "; | 3467 const char* prefix = "[object "; |
| 3427 Local<String> str = Utils::ToLocal(class_name); | 3468 Local<String> str = Utils::ToLocal(class_name); |
| 3428 const char* postfix = "]"; | 3469 const char* postfix = "]"; |
| 3429 | 3470 |
| 3430 int prefix_len = i::StrLength(prefix); | 3471 int prefix_len = i::StrLength(prefix); |
| 3431 int str_len = str->Utf8Length(); | 3472 int str_len = str->Utf8Length(); |
| 3432 int postfix_len = i::StrLength(postfix); | 3473 int postfix_len = i::StrLength(postfix); |
| 3433 | 3474 |
| 3434 int buf_len = prefix_len + str_len + postfix_len; | 3475 int buf_len = prefix_len + str_len + postfix_len; |
| 3435 i::ScopedVector<char> buf(buf_len); | 3476 i::ScopedVector<char> buf(buf_len); |
| 3436 | 3477 |
| 3437 // Write prefix. | 3478 // Write prefix. |
| 3438 char* ptr = buf.start(); | 3479 char* ptr = buf.start(); |
| 3439 i::OS::MemCopy(ptr, prefix, prefix_len * v8::internal::kCharSize); | 3480 i::OS::MemCopy(ptr, prefix, prefix_len * v8::internal::kCharSize); |
| 3440 ptr += prefix_len; | 3481 ptr += prefix_len; |
| 3441 | 3482 |
| 3442 // Write real content. | 3483 // Write real content. |
| 3443 str->WriteUtf8(ptr, str_len); | 3484 str->WriteUtf8(ptr, str_len); |
| 3444 ptr += str_len; | 3485 ptr += str_len; |
| 3445 | 3486 |
| 3446 // Write postfix. | 3487 // Write postfix. |
| 3447 i::OS::MemCopy(ptr, postfix, postfix_len * v8::internal::kCharSize); | 3488 i::OS::MemCopy(ptr, postfix, postfix_len * v8::internal::kCharSize); |
| 3448 | 3489 |
| 3449 // Copy the buffer into a heap-allocated string and return it. | 3490 // Copy the buffer into a heap-allocated string and return it. |
| 3450 Local<String> result = v8::String::New(buf.start(), buf_len); | 3491 Local<String> result = v8::String::NewFromUtf8( |
| 3492 isolate, buf.start(), String::kNormalString, buf_len); |
| 3451 return result; | 3493 return result; |
| 3452 } | 3494 } |
| 3453 } | 3495 } |
| 3454 } | 3496 } |
| 3455 | 3497 |
| 3456 | 3498 |
| 3457 Local<Value> v8::Object::GetConstructor() { | 3499 Local<Value> v8::Object::GetConstructor() { |
| 3458 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3500 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3459 ON_BAILOUT(isolate, "v8::Object::GetConstructor()", | 3501 ON_BAILOUT(isolate, "v8::Object::GetConstructor()", |
| 3460 return Local<v8::Function>()); | 3502 return Local<v8::Function>()); |
| (...skipping 1577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5038 // Obscure semantics for undefined, but somehow checked in our unit tests... | 5080 // Obscure semantics for undefined, but somehow checked in our unit tests... |
| 5039 if (obj->IsUndefined()) return NULL; | 5081 if (obj->IsUndefined()) return NULL; |
| 5040 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0); | 5082 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0); |
| 5041 return i::Foreign::cast(foreign)->foreign_address(); | 5083 return i::Foreign::cast(foreign)->foreign_address(); |
| 5042 } | 5084 } |
| 5043 | 5085 |
| 5044 | 5086 |
| 5045 // --- E n v i r o n m e n t --- | 5087 // --- E n v i r o n m e n t --- |
| 5046 | 5088 |
| 5047 | 5089 |
| 5090 void v8::V8::InitializePlatform(Platform* platform) { |
| 5091 #ifdef V8_USE_DEFAULT_PLATFORM |
| 5092 FATAL("Can't override v8::Platform when using default implementation"); |
| 5093 #else |
| 5094 i::V8::InitializePlatform(platform); |
| 5095 #endif |
| 5096 } |
| 5097 |
| 5098 |
| 5099 void v8::V8::ShutdownPlatform() { |
| 5100 #ifdef V8_USE_DEFAULT_PLATFORM |
| 5101 FATAL("Can't override v8::Platform when using default implementation"); |
| 5102 #else |
| 5103 i::V8::ShutdownPlatform(); |
| 5104 #endif |
| 5105 } |
| 5106 |
| 5107 |
| 5048 bool v8::V8::Initialize() { | 5108 bool v8::V8::Initialize() { |
| 5049 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 5109 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| 5050 if (isolate != NULL && isolate->IsInitialized()) { | 5110 if (isolate != NULL && isolate->IsInitialized()) { |
| 5051 return true; | 5111 return true; |
| 5052 } | 5112 } |
| 5053 return InitializeHelper(isolate); | 5113 return InitializeHelper(isolate); |
| 5054 } | 5114 } |
| 5055 | 5115 |
| 5056 | 5116 |
| 5057 void v8::V8::SetEntropySource(EntropySource entropy_source) { | 5117 void v8::V8::SetEntropySource(EntropySource entropy_source) { |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5621 ASSERT(parent->IsSlicedString()); | 5681 ASSERT(parent->IsSlicedString()); |
| 5622 i::Handle<i::SlicedString> slice = i::Handle<i::SlicedString>::cast(parent); | 5682 i::Handle<i::SlicedString> slice = i::Handle<i::SlicedString>::cast(parent); |
| 5623 slice->set_parent(*external); | 5683 slice->set_parent(*external); |
| 5624 slice->set_offset(0); | 5684 slice->set_offset(0); |
| 5625 } | 5685 } |
| 5626 return true; | 5686 return true; |
| 5627 } | 5687 } |
| 5628 | 5688 |
| 5629 | 5689 |
| 5630 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( |
| 5631 v8::String::ExternalStringResource* resource) { | 5705 v8::String::ExternalStringResource* resource) { |
| 5632 i::Isolate* isolate = i::Isolate::Current(); | 5706 return NewExternal(Isolate::GetCurrent(), resource); |
| 5633 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); | |
| 5634 LOG_API(isolate, "String::NewExternal"); | |
| 5635 ENTER_V8(isolate); | |
| 5636 CHECK(resource && resource->data()); | |
| 5637 i::Handle<i::String> result = NewExternalStringHandle(isolate, resource); | |
| 5638 isolate->heap()->external_string_table()->AddString(*result); | |
| 5639 return Utils::ToLocal(result); | |
| 5640 } | 5707 } |
| 5641 | 5708 |
| 5642 | 5709 |
| 5643 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { | 5710 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { |
| 5644 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5711 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 5645 i::Isolate* isolate = obj->GetIsolate(); | 5712 i::Isolate* isolate = obj->GetIsolate(); |
| 5646 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5713 if (i::StringShape(*obj).IsExternalTwoByte()) { |
| 5647 return false; // Already an external string. | 5714 return false; // Already an external string. |
| 5648 } | 5715 } |
| 5649 ENTER_V8(isolate); | 5716 ENTER_V8(isolate); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 5670 | 5737 |
| 5671 ASSERT(external->IsExternalString()); | 5738 ASSERT(external->IsExternalString()); |
| 5672 if (result && !external->IsInternalizedString()) { | 5739 if (result && !external->IsInternalizedString()) { |
| 5673 isolate->heap()->external_string_table()->AddString(*external); | 5740 isolate->heap()->external_string_table()->AddString(*external); |
| 5674 } | 5741 } |
| 5675 return result; | 5742 return result; |
| 5676 } | 5743 } |
| 5677 | 5744 |
| 5678 | 5745 |
| 5679 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( |
| 5680 v8::String::ExternalAsciiStringResource* resource) { | 5762 v8::String::ExternalAsciiStringResource* resource) { |
| 5681 i::Isolate* isolate = i::Isolate::Current(); | 5763 return NewExternal(Isolate::GetCurrent(), resource); |
| 5682 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); | |
| 5683 LOG_API(isolate, "String::NewExternal"); | |
| 5684 ENTER_V8(isolate); | |
| 5685 CHECK(resource && resource->data()); | |
| 5686 i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource); | |
| 5687 isolate->heap()->external_string_table()->AddString(*result); | |
| 5688 return Utils::ToLocal(result); | |
| 5689 } | 5764 } |
| 5690 | 5765 |
| 5691 | 5766 |
| 5692 bool v8::String::MakeExternal( | 5767 bool v8::String::MakeExternal( |
| 5693 v8::String::ExternalAsciiStringResource* resource) { | 5768 v8::String::ExternalAsciiStringResource* resource) { |
| 5694 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5769 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 5695 i::Isolate* isolate = obj->GetIsolate(); | 5770 i::Isolate* isolate = obj->GetIsolate(); |
| 5696 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5771 if (i::StringShape(*obj).IsExternalTwoByte()) { |
| 5697 return false; // Already an external string. | 5772 return false; // Already an external string. |
| 5698 } | 5773 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5737 if (isolate->heap()->old_pointer_space()->Contains(*obj)) return false; | 5812 if (isolate->heap()->old_pointer_space()->Contains(*obj)) return false; |
| 5738 | 5813 |
| 5739 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; | 5814 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; |
| 5740 int size = obj->Size(); // Byte size of the original string. | 5815 int size = obj->Size(); // Byte size of the original string. |
| 5741 if (size < i::ExternalString::kShortSize) return false; | 5816 if (size < i::ExternalString::kShortSize) return false; |
| 5742 i::StringShape shape(*obj); | 5817 i::StringShape shape(*obj); |
| 5743 return !shape.IsExternal(); | 5818 return !shape.IsExternal(); |
| 5744 } | 5819 } |
| 5745 | 5820 |
| 5746 | 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 |
| 5747 Local<v8::Object> v8::Object::New() { | 5833 Local<v8::Object> v8::Object::New() { |
| 5748 i::Isolate* isolate = i::Isolate::Current(); | 5834 return New(Isolate::GetCurrent()); |
| 5749 EnsureInitializedForIsolate(isolate, "v8::Object::New()"); | 5835 } |
| 5750 LOG_API(isolate, "Object::New"); | 5836 |
| 5751 ENTER_V8(isolate); | 5837 |
| 5752 i::Handle<i::JSObject> obj = | 5838 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) { |
| 5753 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); |
| 5754 return Utils::ToLocal(obj); | 5845 return Utils::ToLocal(obj); |
| 5755 } | 5846 } |
| 5756 | 5847 |
| 5757 | 5848 |
| 5758 Local<v8::Value> v8::NumberObject::New(double value) { | 5849 Local<v8::Value> v8::NumberObject::New(double value) { |
| 5759 i::Isolate* isolate = i::Isolate::Current(); | 5850 return New(Isolate::GetCurrent(), value); |
| 5760 EnsureInitializedForIsolate(isolate, "v8::NumberObject::New()"); | |
| 5761 LOG_API(isolate, "NumberObject::New"); | |
| 5762 ENTER_V8(isolate); | |
| 5763 i::Handle<i::Object> number = isolate->factory()->NewNumber(value); | |
| 5764 i::Handle<i::Object> obj = isolate->factory()->ToObject(number); | |
| 5765 return Utils::ToLocal(obj); | |
| 5766 } | 5851 } |
| 5767 | 5852 |
| 5768 | 5853 |
| 5769 double v8::NumberObject::ValueOf() const { | 5854 double v8::NumberObject::ValueOf() const { |
| 5770 i::Isolate* isolate = i::Isolate::Current(); | 5855 i::Isolate* isolate = i::Isolate::Current(); |
| 5771 LOG_API(isolate, "NumberObject::NumberValue"); | 5856 LOG_API(isolate, "NumberObject::NumberValue"); |
| 5772 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5857 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 5773 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5858 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
| 5774 return jsvalue->value()->Number(); | 5859 return jsvalue->value()->Number(); |
| 5775 } | 5860 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5833 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { | 5918 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { |
| 5834 i::Isolate* isolate = i::Isolate::Current(); | 5919 i::Isolate* isolate = i::Isolate::Current(); |
| 5835 LOG_API(isolate, "SymbolObject::SymbolValue"); | 5920 LOG_API(isolate, "SymbolObject::SymbolValue"); |
| 5836 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5921 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 5837 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5922 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
| 5838 return Utils::ToLocal( | 5923 return Utils::ToLocal( |
| 5839 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); | 5924 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); |
| 5840 } | 5925 } |
| 5841 | 5926 |
| 5842 | 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 |
| 5843 Local<v8::Value> v8::Date::New(double time) { | 5945 Local<v8::Value> v8::Date::New(double time) { |
| 5844 i::Isolate* isolate = i::Isolate::Current(); | 5946 return New(Isolate::GetCurrent(), time); |
| 5845 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); | |
| 5846 LOG_API(isolate, "Date::New"); | |
| 5847 if (std::isnan(time)) { | |
| 5848 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | |
| 5849 time = i::OS::nan_value(); | |
| 5850 } | |
| 5851 ENTER_V8(isolate); | |
| 5852 EXCEPTION_PREAMBLE(isolate); | |
| 5853 i::Handle<i::Object> obj = | |
| 5854 i::Execution::NewDate(isolate, time, &has_pending_exception); | |
| 5855 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Value>()); | |
| 5856 return Utils::ToLocal(obj); | |
| 5857 } | 5947 } |
| 5858 | 5948 |
| 5859 | 5949 |
| 5860 double v8::Date::ValueOf() const { | 5950 double v8::Date::ValueOf() const { |
| 5861 i::Isolate* isolate = i::Isolate::Current(); | 5951 i::Isolate* isolate = i::Isolate::Current(); |
| 5862 LOG_API(isolate, "Date::NumberValue"); | 5952 LOG_API(isolate, "Date::NumberValue"); |
| 5863 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5953 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 5864 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); | 5954 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); |
| 5865 return jsdate->value()->Number(); | 5955 return jsdate->value()->Number(); |
| 5866 } | 5956 } |
| 5867 | 5957 |
| 5868 | 5958 |
| 5869 void v8::Date::DateTimeConfigurationChangeNotification() { | 5959 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { |
| 5870 i::Isolate* isolate = i::Isolate::Current(); | 5960 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5871 ON_BAILOUT(isolate, "v8::Date::DateTimeConfigurationChangeNotification()", | 5961 ON_BAILOUT(i_isolate, "v8::Date::DateTimeConfigurationChangeNotification()", |
| 5872 return); | 5962 return); |
| 5873 LOG_API(isolate, "Date::DateTimeConfigurationChangeNotification"); | 5963 LOG_API(i_isolate, "Date::DateTimeConfigurationChangeNotification"); |
| 5874 ENTER_V8(isolate); | 5964 ENTER_V8(i_isolate); |
| 5875 | 5965 |
| 5876 isolate->date_cache()->ResetDateCache(); | 5966 i_isolate->date_cache()->ResetDateCache(); |
| 5877 | 5967 |
| 5878 i::HandleScope scope(isolate); | 5968 i::HandleScope scope(i_isolate); |
| 5879 // Get the function ResetDateCache (defined in date.js). | 5969 // Get the function ResetDateCache (defined in date.js). |
| 5880 i::Handle<i::String> func_name_str = | 5970 i::Handle<i::String> func_name_str = |
| 5881 isolate->factory()->InternalizeOneByteString( | 5971 i_isolate->factory()->InternalizeOneByteString( |
| 5882 STATIC_ASCII_VECTOR("ResetDateCache")); | 5972 STATIC_ASCII_VECTOR("ResetDateCache")); |
| 5883 i::MaybeObject* result = | 5973 i::MaybeObject* result = |
| 5884 isolate->js_builtins_object()->GetProperty(*func_name_str); | 5974 i_isolate->js_builtins_object()->GetProperty(*func_name_str); |
| 5885 i::Object* object_func; | 5975 i::Object* object_func; |
| 5886 if (!result->ToObject(&object_func)) { | 5976 if (!result->ToObject(&object_func)) { |
| 5887 return; | 5977 return; |
| 5888 } | 5978 } |
| 5889 | 5979 |
| 5890 if (object_func->IsJSFunction()) { | 5980 if (object_func->IsJSFunction()) { |
| 5891 i::Handle<i::JSFunction> func = | 5981 i::Handle<i::JSFunction> func = |
| 5892 i::Handle<i::JSFunction>(i::JSFunction::cast(object_func)); | 5982 i::Handle<i::JSFunction>(i::JSFunction::cast(object_func)); |
| 5893 | 5983 |
| 5894 // Call ResetDateCache(0 but expect no exceptions: | 5984 // Call ResetDateCache(0 but expect no exceptions: |
| 5895 bool caught_exception = false; | 5985 bool caught_exception = false; |
| 5896 i::Execution::TryCall(func, | 5986 i::Execution::TryCall(func, |
| 5897 isolate->js_builtins_object(), | 5987 i_isolate->js_builtins_object(), |
| 5898 0, | 5988 0, |
| 5899 NULL, | 5989 NULL, |
| 5900 &caught_exception); | 5990 &caught_exception); |
| 5901 } | 5991 } |
| 5902 } | 5992 } |
| 5903 | 5993 |
| 5904 | 5994 |
| 5995 void v8::Date::DateTimeConfigurationChangeNotification() { |
| 5996 DateTimeConfigurationChangeNotification(Isolate::GetCurrent()); |
| 5997 } |
| 5998 |
| 5999 |
| 5905 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { | 6000 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { |
| 5906 i::Isolate* isolate = i::Isolate::Current(); | 6001 i::Isolate* isolate = i::Isolate::Current(); |
| 5907 uint8_t flags_buf[3]; | 6002 uint8_t flags_buf[3]; |
| 5908 int num_flags = 0; | 6003 int num_flags = 0; |
| 5909 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; | 6004 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; |
| 5910 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; | 6005 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; |
| 5911 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; | 6006 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; |
| 5912 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); | 6007 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); |
| 5913 return isolate->factory()->InternalizeOneByteString( | 6008 return isolate->factory()->InternalizeOneByteString( |
| 5914 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... |
| 5946 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE); | 6041 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE); |
| 5947 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE); | 6042 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE); |
| 5948 #undef REGEXP_FLAG_ASSERT_EQ | 6043 #undef REGEXP_FLAG_ASSERT_EQ |
| 5949 | 6044 |
| 5950 v8::RegExp::Flags v8::RegExp::GetFlags() const { | 6045 v8::RegExp::Flags v8::RegExp::GetFlags() const { |
| 5951 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); | 6046 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); |
| 5952 return static_cast<RegExp::Flags>(obj->GetFlags().value()); | 6047 return static_cast<RegExp::Flags>(obj->GetFlags().value()); |
| 5953 } | 6048 } |
| 5954 | 6049 |
| 5955 | 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 |
| 5956 Local<v8::Array> v8::Array::New(int length) { | 6065 Local<v8::Array> v8::Array::New(int length) { |
| 5957 i::Isolate* isolate = i::Isolate::Current(); | 6066 return New(Isolate::GetCurrent(), length); |
| 5958 EnsureInitializedForIsolate(isolate, "v8::Array::New()"); | |
| 5959 LOG_API(isolate, "Array::New"); | |
| 5960 ENTER_V8(isolate); | |
| 5961 int real_length = length > 0 ? length : 0; | |
| 5962 i::Handle<i::JSArray> obj = isolate->factory()->NewJSArray(real_length); | |
| 5963 i::Handle<i::Object> length_obj = | |
| 5964 isolate->factory()->NewNumberFromInt(real_length); | |
| 5965 obj->set_length(*length_obj); | |
| 5966 return Utils::ToLocal(obj); | |
| 5967 } | 6067 } |
| 5968 | 6068 |
| 5969 | 6069 |
| 5970 uint32_t v8::Array::Length() const { | 6070 uint32_t v8::Array::Length() const { |
| 5971 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); | 6071 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); |
| 5972 i::Object* length = obj->length(); | 6072 i::Object* length = obj->length(); |
| 5973 if (length->IsSmi()) { | 6073 if (length->IsSmi()) { |
| 5974 return i::Smi::cast(length)->value(); | 6074 return i::Smi::cast(length)->value(); |
| 5975 } else { | 6075 } else { |
| 5976 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... |
| 6043 obj->Neuter(); | 6143 obj->Neuter(); |
| 6044 } | 6144 } |
| 6045 | 6145 |
| 6046 | 6146 |
| 6047 size_t v8::ArrayBuffer::ByteLength() const { | 6147 size_t v8::ArrayBuffer::ByteLength() const { |
| 6048 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 6148 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
| 6049 return static_cast<size_t>(obj->byte_length()->Number()); | 6149 return static_cast<size_t>(obj->byte_length()->Number()); |
| 6050 } | 6150 } |
| 6051 | 6151 |
| 6052 | 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 |
| 6053 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) { | 6165 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) { |
| 6054 i::Isolate* isolate = i::Isolate::Current(); | 6166 return New(Isolate::GetCurrent(), byte_length); |
| 6055 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(size_t)"); | 6167 } |
| 6056 LOG_API(isolate, "v8::ArrayBuffer::New(size_t)"); | 6168 |
| 6057 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); |
| 6058 i::Handle<i::JSArrayBuffer> obj = | 6176 i::Handle<i::JSArrayBuffer> obj = |
| 6059 isolate->factory()->NewJSArrayBuffer(); | 6177 i_isolate->factory()->NewJSArrayBuffer(); |
| 6060 i::Runtime::SetupArrayBufferAllocatingData(isolate, obj, byte_length); | 6178 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); |
| 6061 return Utils::ToLocal(obj); | 6179 return Utils::ToLocal(obj); |
| 6062 } | 6180 } |
| 6063 | 6181 |
| 6064 | 6182 |
| 6065 Local<ArrayBuffer> v8::ArrayBuffer::New(void* data, size_t byte_length) { | 6183 Local<ArrayBuffer> v8::ArrayBuffer::New(void* data, size_t byte_length) { |
| 6066 i::Isolate* isolate = i::Isolate::Current(); | 6184 return New(Isolate::GetCurrent(), data, byte_length); |
| 6067 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(void*, size_t)"); | |
| 6068 LOG_API(isolate, "v8::ArrayBuffer::New(void*, size_t)"); | |
| 6069 ENTER_V8(isolate); | |
| 6070 i::Handle<i::JSArrayBuffer> obj = | |
| 6071 isolate->factory()->NewJSArrayBuffer(); | |
| 6072 i::Runtime::SetupArrayBuffer(isolate, obj, true, data, byte_length); | |
| 6073 return Utils::ToLocal(obj); | |
| 6074 } | 6185 } |
| 6075 | 6186 |
| 6076 | 6187 |
| 6077 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { | 6188 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { |
| 6078 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 6189 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
| 6079 ASSERT(obj->buffer()->IsJSArrayBuffer()); | 6190 ASSERT(obj->buffer()->IsJSArrayBuffer()); |
| 6080 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); | 6191 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); |
| 6081 return Utils::ToLocal(buffer); | 6192 return Utils::ToLocal(buffer); |
| 6082 } | 6193 } |
| 6083 | 6194 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6255 } | 6366 } |
| 6256 ENTER_V8(internal_isolate); | 6367 ENTER_V8(internal_isolate); |
| 6257 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 6368 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
| 6258 return Utils::NumberToLocal(result); | 6369 return Utils::NumberToLocal(result); |
| 6259 } | 6370 } |
| 6260 | 6371 |
| 6261 | 6372 |
| 6262 Local<Integer> v8::Integer::New(int32_t value) { | 6373 Local<Integer> v8::Integer::New(int32_t value) { |
| 6263 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 6374 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| 6264 EnsureInitializedForIsolate(isolate, "v8::Integer::New()"); | 6375 EnsureInitializedForIsolate(isolate, "v8::Integer::New()"); |
| 6265 return v8::Integer::New(value, reinterpret_cast<Isolate*>(isolate)); | 6376 return v8::Integer::New(reinterpret_cast<Isolate*>(isolate), value); |
| 6266 } | 6377 } |
| 6267 | 6378 |
| 6268 | 6379 |
| 6269 Local<Integer> Integer::NewFromUnsigned(uint32_t value) { | 6380 Local<Integer> Integer::NewFromUnsigned(uint32_t value) { |
| 6270 i::Isolate* isolate = i::Isolate::Current(); | 6381 i::Isolate* isolate = i::Isolate::Current(); |
| 6271 EnsureInitializedForIsolate(isolate, "v8::Integer::NewFromUnsigned()"); | 6382 EnsureInitializedForIsolate(isolate, "v8::Integer::NewFromUnsigned()"); |
| 6272 return Integer::NewFromUnsigned(value, reinterpret_cast<Isolate*>(isolate)); | 6383 return Integer::NewFromUnsigned(reinterpret_cast<Isolate*>(isolate), value); |
| 6273 } | 6384 } |
| 6274 | 6385 |
| 6275 | 6386 |
| 6276 Local<Integer> v8::Integer::New(int32_t value, Isolate* isolate) { | 6387 Local<Integer> v8::Integer::New(int32_t value, Isolate* isolate) { |
| 6388 return Integer::New(isolate, value); |
| 6389 } |
| 6390 |
| 6391 |
| 6392 Local<Integer> v8::Integer::NewFromUnsigned(uint32_t value, Isolate* isolate) { |
| 6393 return Integer::NewFromUnsigned(isolate, value); |
| 6394 } |
| 6395 |
| 6396 |
| 6397 Local<Integer> v8::Integer::New(Isolate* isolate, int32_t value) { |
| 6277 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6398 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6278 ASSERT(internal_isolate->IsInitialized()); | 6399 ASSERT(internal_isolate->IsInitialized()); |
| 6279 if (i::Smi::IsValid(value)) { | 6400 if (i::Smi::IsValid(value)) { |
| 6280 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value), | 6401 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value), |
| 6281 internal_isolate)); | 6402 internal_isolate)); |
| 6282 } | 6403 } |
| 6283 ENTER_V8(internal_isolate); | 6404 ENTER_V8(internal_isolate); |
| 6284 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 6405 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
| 6285 return Utils::IntegerToLocal(result); | 6406 return Utils::IntegerToLocal(result); |
| 6286 } | 6407 } |
| 6287 | 6408 |
| 6288 | 6409 |
| 6289 Local<Integer> v8::Integer::NewFromUnsigned(uint32_t value, Isolate* isolate) { | 6410 Local<Integer> v8::Integer::NewFromUnsigned(Isolate* isolate, uint32_t value) { |
| 6290 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6411 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6291 ASSERT(internal_isolate->IsInitialized()); | 6412 ASSERT(internal_isolate->IsInitialized()); |
| 6292 bool fits_into_int32_t = (value & (1 << 31)) == 0; | 6413 bool fits_into_int32_t = (value & (1 << 31)) == 0; |
| 6293 if (fits_into_int32_t) { | 6414 if (fits_into_int32_t) { |
| 6294 return Integer::New(static_cast<int32_t>(value), isolate); | 6415 return Integer::New(static_cast<int32_t>(value), isolate); |
| 6295 } | 6416 } |
| 6296 ENTER_V8(internal_isolate); | 6417 ENTER_V8(internal_isolate); |
| 6297 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 6418 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
| 6298 return Utils::IntegerToLocal(result); | 6419 return Utils::IntegerToLocal(result); |
| 6299 } | 6420 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6382 SetAddHistogramSampleFunction(callback); | 6503 SetAddHistogramSampleFunction(callback); |
| 6383 } | 6504 } |
| 6384 | 6505 |
| 6385 void V8::SetFailedAccessCheckCallbackFunction( | 6506 void V8::SetFailedAccessCheckCallbackFunction( |
| 6386 FailedAccessCheckCallback callback) { | 6507 FailedAccessCheckCallback callback) { |
| 6387 i::Isolate* isolate = i::Isolate::Current(); | 6508 i::Isolate* isolate = i::Isolate::Current(); |
| 6388 isolate->SetFailedAccessCheckCallback(callback); | 6509 isolate->SetFailedAccessCheckCallback(callback); |
| 6389 } | 6510 } |
| 6390 | 6511 |
| 6391 | 6512 |
| 6392 intptr_t Isolate::AdjustAmountOfExternalAllocatedMemory( | 6513 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( |
| 6393 intptr_t change_in_bytes) { | 6514 int64_t change_in_bytes) { |
| 6394 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); | 6515 i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap(); |
| 6395 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); | 6516 return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); |
| 6396 } | 6517 } |
| 6397 | 6518 |
| 6398 | 6519 |
| 6399 intptr_t V8::AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes) { | 6520 int64_t V8::AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes) { |
| 6400 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 6521 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| 6401 if (isolate == NULL || !isolate->IsInitialized()) { | 6522 if (isolate == NULL || !isolate->IsInitialized()) { |
| 6402 return 0; | 6523 return 0; |
| 6403 } | 6524 } |
| 6404 Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate); | 6525 Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate); |
| 6405 return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); | 6526 return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes); |
| 6406 } | 6527 } |
| 6407 | 6528 |
| 6408 | 6529 |
| 6409 HeapProfiler* Isolate::GetHeapProfiler() { | 6530 HeapProfiler* Isolate::GetHeapProfiler() { |
| (...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7660 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7781 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7661 Address callback_address = | 7782 Address callback_address = |
| 7662 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7783 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7663 VMState<EXTERNAL> state(isolate); | 7784 VMState<EXTERNAL> state(isolate); |
| 7664 ExternalCallbackScope call_scope(isolate, callback_address); | 7785 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7665 callback(info); | 7786 callback(info); |
| 7666 } | 7787 } |
| 7667 | 7788 |
| 7668 | 7789 |
| 7669 } } // namespace v8::internal | 7790 } } // namespace v8::internal |
| OLD | NEW |