| 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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2101 } | 2130 } |
| 2102 | 2131 |
| 2103 | 2132 |
| 2104 // --- M e s s a g e --- | 2133 // --- M e s s a g e --- |
| 2105 | 2134 |
| 2106 | 2135 |
| 2107 Local<String> Message::Get() const { | 2136 Local<String> Message::Get() const { |
| 2108 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2137 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2109 ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>()); | 2138 ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>()); |
| 2110 ENTER_V8(isolate); | 2139 ENTER_V8(isolate); |
| 2111 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2140 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2112 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2141 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 2113 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj); | 2142 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj); |
| 2114 Local<String> result = Utils::ToLocal(raw_result); | 2143 Local<String> result = Utils::ToLocal(raw_result); |
| 2115 return scope.Close(result); | 2144 return scope.Escape(result); |
| 2116 } | 2145 } |
| 2117 | 2146 |
| 2118 | 2147 |
| 2119 v8::Handle<Value> Message::GetScriptResourceName() const { | 2148 v8::Handle<Value> Message::GetScriptResourceName() const { |
| 2120 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2149 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2121 ENTER_V8(isolate); | 2150 ENTER_V8(isolate); |
| 2122 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2151 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2123 i::Handle<i::JSMessageObject> message = | 2152 i::Handle<i::JSMessageObject> message = |
| 2124 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2153 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
| 2125 // Return this.script.name. | 2154 // Return this.script.name. |
| 2126 i::Handle<i::JSValue> script = | 2155 i::Handle<i::JSValue> script = |
| 2127 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), | 2156 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), |
| 2128 isolate)); | 2157 isolate)); |
| 2129 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name(), | 2158 i::Handle<i::Object> resource_name(i::Script::cast(script->value())->name(), |
| 2130 isolate); | 2159 isolate); |
| 2131 return scope.Close(Utils::ToLocal(resource_name)); | 2160 return scope.Escape(Utils::ToLocal(resource_name)); |
| 2132 } | 2161 } |
| 2133 | 2162 |
| 2134 | 2163 |
| 2135 v8::Handle<Value> Message::GetScriptData() const { | 2164 v8::Handle<Value> Message::GetScriptData() const { |
| 2136 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2165 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2137 ENTER_V8(isolate); | 2166 ENTER_V8(isolate); |
| 2138 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2167 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2139 i::Handle<i::JSMessageObject> message = | 2168 i::Handle<i::JSMessageObject> message = |
| 2140 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2169 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
| 2141 // Return this.script.data. | 2170 // Return this.script.data. |
| 2142 i::Handle<i::JSValue> script = | 2171 i::Handle<i::JSValue> script = |
| 2143 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), | 2172 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), |
| 2144 isolate)); | 2173 isolate)); |
| 2145 i::Handle<i::Object> data(i::Script::cast(script->value())->data(), isolate); | 2174 i::Handle<i::Object> data(i::Script::cast(script->value())->data(), isolate); |
| 2146 return scope.Close(Utils::ToLocal(data)); | 2175 return scope.Escape(Utils::ToLocal(data)); |
| 2147 } | 2176 } |
| 2148 | 2177 |
| 2149 | 2178 |
| 2150 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { | 2179 v8::Handle<v8::StackTrace> Message::GetStackTrace() const { |
| 2151 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2180 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2152 ENTER_V8(isolate); | 2181 ENTER_V8(isolate); |
| 2153 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2182 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2154 i::Handle<i::JSMessageObject> message = | 2183 i::Handle<i::JSMessageObject> message = |
| 2155 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2184 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
| 2156 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); | 2185 i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate); |
| 2157 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); | 2186 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); |
| 2158 i::Handle<i::JSArray> stackTrace = | 2187 i::Handle<i::JSArray> stackTrace = |
| 2159 i::Handle<i::JSArray>::cast(stackFramesObj); | 2188 i::Handle<i::JSArray>::cast(stackFramesObj); |
| 2160 return scope.Close(Utils::StackTraceToLocal(stackTrace)); | 2189 return scope.Escape(Utils::StackTraceToLocal(stackTrace)); |
| 2161 } | 2190 } |
| 2162 | 2191 |
| 2163 | 2192 |
| 2164 static i::Handle<i::Object> CallV8HeapFunction(const char* name, | 2193 static i::Handle<i::Object> CallV8HeapFunction(const char* name, |
| 2165 i::Handle<i::Object> recv, | 2194 i::Handle<i::Object> recv, |
| 2166 int argc, | 2195 int argc, |
| 2167 i::Handle<i::Object> argv[], | 2196 i::Handle<i::Object> argv[], |
| 2168 bool* has_pending_exception) { | 2197 bool* has_pending_exception) { |
| 2169 i::Isolate* isolate = i::Isolate::Current(); | 2198 i::Isolate* isolate = i::Isolate::Current(); |
| 2170 i::Handle<i::String> fmt_str = | 2199 i::Handle<i::String> fmt_str = |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2270 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), | 2299 i::Handle<i::JSValue>::cast(i::Handle<i::Object>(message->script(), |
| 2271 isolate)); | 2300 isolate)); |
| 2272 return i::Script::cast(script->value())->is_shared_cross_origin(); | 2301 return i::Script::cast(script->value())->is_shared_cross_origin(); |
| 2273 } | 2302 } |
| 2274 | 2303 |
| 2275 | 2304 |
| 2276 Local<String> Message::GetSourceLine() const { | 2305 Local<String> Message::GetSourceLine() const { |
| 2277 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2306 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2278 ON_BAILOUT(isolate, "v8::Message::GetSourceLine()", return Local<String>()); | 2307 ON_BAILOUT(isolate, "v8::Message::GetSourceLine()", return Local<String>()); |
| 2279 ENTER_V8(isolate); | 2308 ENTER_V8(isolate); |
| 2280 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2309 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2281 EXCEPTION_PREAMBLE(isolate); | 2310 EXCEPTION_PREAMBLE(isolate); |
| 2282 i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine", | 2311 i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine", |
| 2283 Utils::OpenHandle(this), | 2312 Utils::OpenHandle(this), |
| 2284 &has_pending_exception); | 2313 &has_pending_exception); |
| 2285 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::String>()); | 2314 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::String>()); |
| 2286 if (result->IsString()) { | 2315 if (result->IsString()) { |
| 2287 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result))); | 2316 return scope.Escape(Utils::ToLocal(i::Handle<i::String>::cast(result))); |
| 2288 } else { | 2317 } else { |
| 2289 return Local<String>(); | 2318 return Local<String>(); |
| 2290 } | 2319 } |
| 2291 } | 2320 } |
| 2292 | 2321 |
| 2293 | 2322 |
| 2294 void Message::PrintCurrentStackTrace(FILE* out) { | 2323 void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) { |
| 2295 i::Isolate* isolate = i::Isolate::Current(); | 2324 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 2296 ENTER_V8(isolate); | 2325 ENTER_V8(i_isolate); |
| 2297 isolate->PrintCurrentStackTrace(out); | 2326 i_isolate->PrintCurrentStackTrace(out); |
| 2298 } | 2327 } |
| 2299 | 2328 |
| 2300 | 2329 |
| 2330 void Message::PrintCurrentStackTrace(FILE* out) { |
| 2331 PrintCurrentStackTrace(Isolate::GetCurrent(), out); |
| 2332 } |
| 2333 |
| 2334 |
| 2301 // --- S t a c k T r a c e --- | 2335 // --- S t a c k T r a c e --- |
| 2302 | 2336 |
| 2303 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { | 2337 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { |
| 2304 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2338 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2305 ENTER_V8(isolate); | 2339 ENTER_V8(isolate); |
| 2306 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2340 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2307 i::Handle<i::JSArray> self = Utils::OpenHandle(this); | 2341 i::Handle<i::JSArray> self = Utils::OpenHandle(this); |
| 2308 i::Object* raw_object = self->GetElementNoExceptionThrown(isolate, index); | 2342 i::Object* raw_object = self->GetElementNoExceptionThrown(isolate, index); |
| 2309 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object)); | 2343 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object)); |
| 2310 return scope.Close(Utils::StackFrameToLocal(obj)); | 2344 return scope.Escape(Utils::StackFrameToLocal(obj)); |
| 2311 } | 2345 } |
| 2312 | 2346 |
| 2313 | 2347 |
| 2314 int StackTrace::GetFrameCount() const { | 2348 int StackTrace::GetFrameCount() const { |
| 2315 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2349 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2316 ENTER_V8(isolate); | 2350 ENTER_V8(isolate); |
| 2317 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); | 2351 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); |
| 2318 } | 2352 } |
| 2319 | 2353 |
| 2320 | 2354 |
| 2321 Local<Array> StackTrace::AsArray() { | 2355 Local<Array> StackTrace::AsArray() { |
| 2322 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2356 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2323 ENTER_V8(isolate); | 2357 ENTER_V8(isolate); |
| 2324 return Utils::ToLocal(Utils::OpenHandle(this)); | 2358 return Utils::ToLocal(Utils::OpenHandle(this)); |
| 2325 } | 2359 } |
| 2326 | 2360 |
| 2327 | 2361 |
| 2362 Local<StackTrace> StackTrace::CurrentStackTrace( |
| 2363 Isolate* isolate, |
| 2364 int frame_limit, |
| 2365 StackTraceOptions options) { |
| 2366 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 2367 ENTER_V8(i_isolate); |
| 2368 i::Handle<i::JSArray> stackTrace = |
| 2369 i_isolate->CaptureCurrentStackTrace(frame_limit, options); |
| 2370 return Utils::StackTraceToLocal(stackTrace); |
| 2371 } |
| 2372 |
| 2373 |
| 2328 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit, | 2374 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit, |
| 2329 StackTraceOptions options) { | 2375 StackTraceOptions options) { |
| 2330 i::Isolate* isolate = i::Isolate::Current(); | 2376 return CurrentStackTrace(Isolate::GetCurrent(), frame_limit, options); |
| 2331 ENTER_V8(isolate); | |
| 2332 i::Handle<i::JSArray> stackTrace = | |
| 2333 isolate->CaptureCurrentStackTrace(frame_limit, options); | |
| 2334 return Utils::StackTraceToLocal(stackTrace); | |
| 2335 } | 2377 } |
| 2336 | 2378 |
| 2337 | 2379 |
| 2338 // --- S t a c k F r a m e --- | 2380 // --- S t a c k F r a m e --- |
| 2339 | 2381 |
| 2340 int StackFrame::GetLineNumber() const { | 2382 int StackFrame::GetLineNumber() const { |
| 2341 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2383 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2342 ENTER_V8(isolate); | 2384 ENTER_V8(isolate); |
| 2343 i::HandleScope scope(isolate); | 2385 i::HandleScope scope(isolate); |
| 2344 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2386 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2372 if (!scriptId->IsSmi()) { | 2414 if (!scriptId->IsSmi()) { |
| 2373 return Message::kNoScriptIdInfo; | 2415 return Message::kNoScriptIdInfo; |
| 2374 } | 2416 } |
| 2375 return i::Smi::cast(*scriptId)->value(); | 2417 return i::Smi::cast(*scriptId)->value(); |
| 2376 } | 2418 } |
| 2377 | 2419 |
| 2378 | 2420 |
| 2379 Local<String> StackFrame::GetScriptName() const { | 2421 Local<String> StackFrame::GetScriptName() const { |
| 2380 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2422 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2381 ENTER_V8(isolate); | 2423 ENTER_V8(isolate); |
| 2382 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2424 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2383 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2425 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2384 i::Handle<i::Object> name = GetProperty(self, "scriptName"); | 2426 i::Handle<i::Object> name = GetProperty(self, "scriptName"); |
| 2385 if (!name->IsString()) { | 2427 if (!name->IsString()) { |
| 2386 return Local<String>(); | 2428 return Local<String>(); |
| 2387 } | 2429 } |
| 2388 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); | 2430 return scope.Escape(Local<String>::Cast(Utils::ToLocal(name))); |
| 2389 } | 2431 } |
| 2390 | 2432 |
| 2391 | 2433 |
| 2392 Local<String> StackFrame::GetScriptNameOrSourceURL() const { | 2434 Local<String> StackFrame::GetScriptNameOrSourceURL() const { |
| 2393 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2435 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2394 ENTER_V8(isolate); | 2436 ENTER_V8(isolate); |
| 2395 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2437 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2396 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2438 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2397 i::Handle<i::Object> name = GetProperty(self, "scriptNameOrSourceURL"); | 2439 i::Handle<i::Object> name = GetProperty(self, "scriptNameOrSourceURL"); |
| 2398 if (!name->IsString()) { | 2440 if (!name->IsString()) { |
| 2399 return Local<String>(); | 2441 return Local<String>(); |
| 2400 } | 2442 } |
| 2401 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); | 2443 return scope.Escape(Local<String>::Cast(Utils::ToLocal(name))); |
| 2402 } | 2444 } |
| 2403 | 2445 |
| 2404 | 2446 |
| 2405 Local<String> StackFrame::GetFunctionName() const { | 2447 Local<String> StackFrame::GetFunctionName() const { |
| 2406 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2448 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2407 ENTER_V8(isolate); | 2449 ENTER_V8(isolate); |
| 2408 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2450 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 2409 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2451 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2410 i::Handle<i::Object> name = GetProperty(self, "functionName"); | 2452 i::Handle<i::Object> name = GetProperty(self, "functionName"); |
| 2411 if (!name->IsString()) { | 2453 if (!name->IsString()) { |
| 2412 return Local<String>(); | 2454 return Local<String>(); |
| 2413 } | 2455 } |
| 2414 return scope.Close(Local<String>::Cast(Utils::ToLocal(name))); | 2456 return scope.Escape(Local<String>::Cast(Utils::ToLocal(name))); |
| 2415 } | 2457 } |
| 2416 | 2458 |
| 2417 | 2459 |
| 2418 bool StackFrame::IsEval() const { | 2460 bool StackFrame::IsEval() const { |
| 2419 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2461 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2420 ENTER_V8(isolate); | 2462 ENTER_V8(isolate); |
| 2421 i::HandleScope scope(isolate); | 2463 i::HandleScope scope(isolate); |
| 2422 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2464 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2423 i::Handle<i::Object> is_eval = GetProperty(self, "isEval"); | 2465 i::Handle<i::Object> is_eval = GetProperty(self, "isEval"); |
| 2424 return is_eval->IsTrue(); | 2466 return is_eval->IsTrue(); |
| (...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4011 } | 4053 } |
| 4012 } | 4054 } |
| 4013 | 4055 |
| 4014 | 4056 |
| 4015 bool v8::Object::IsCallable() { | 4057 bool v8::Object::IsCallable() { |
| 4016 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4058 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 4017 ON_BAILOUT(isolate, "v8::Object::IsCallable()", return false); | 4059 ON_BAILOUT(isolate, "v8::Object::IsCallable()", return false); |
| 4018 ENTER_V8(isolate); | 4060 ENTER_V8(isolate); |
| 4019 i::HandleScope scope(isolate); | 4061 i::HandleScope scope(isolate); |
| 4020 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 4062 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
| 4021 if (obj->IsJSFunction()) return true; | 4063 return obj->IsCallable(); |
| 4022 return i::Execution::GetFunctionDelegate(isolate, obj)->IsJSFunction(); | |
| 4023 } | 4064 } |
| 4024 | 4065 |
| 4025 | 4066 |
| 4026 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Value> recv, | 4067 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Value> recv, |
| 4027 int argc, | 4068 int argc, |
| 4028 v8::Handle<v8::Value> argv[]) { | 4069 v8::Handle<v8::Value> argv[]) { |
| 4029 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4070 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 4030 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()", | 4071 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()", |
| 4031 return Local<v8::Value>()); | 4072 return Local<v8::Value>()); |
| 4032 LOG_API(isolate, "Object::CallAsFunction"); | 4073 LOG_API(isolate, "Object::CallAsFunction"); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4116 | 4157 |
| 4117 Local<v8::Object> Function::NewInstance(int argc, | 4158 Local<v8::Object> Function::NewInstance(int argc, |
| 4118 v8::Handle<v8::Value> argv[]) const { | 4159 v8::Handle<v8::Value> argv[]) const { |
| 4119 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4160 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 4120 ON_BAILOUT(isolate, "v8::Function::NewInstance()", | 4161 ON_BAILOUT(isolate, "v8::Function::NewInstance()", |
| 4121 return Local<v8::Object>()); | 4162 return Local<v8::Object>()); |
| 4122 LOG_API(isolate, "Function::NewInstance"); | 4163 LOG_API(isolate, "Function::NewInstance"); |
| 4123 ENTER_V8(isolate); | 4164 ENTER_V8(isolate); |
| 4124 i::Logger::TimerEventScope timer_scope( | 4165 i::Logger::TimerEventScope timer_scope( |
| 4125 isolate, i::Logger::TimerEventScope::v8_execute); | 4166 isolate, i::Logger::TimerEventScope::v8_execute); |
| 4126 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 4167 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 4127 i::Handle<i::JSFunction> function = Utils::OpenHandle(this); | 4168 i::Handle<i::JSFunction> function = Utils::OpenHandle(this); |
| 4128 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 4169 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
| 4129 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4170 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 4130 EXCEPTION_PREAMBLE(isolate); | 4171 EXCEPTION_PREAMBLE(isolate); |
| 4131 i::Handle<i::Object> returned = | 4172 i::Handle<i::Object> returned = |
| 4132 i::Execution::New(function, argc, args, &has_pending_exception); | 4173 i::Execution::New(function, argc, args, &has_pending_exception); |
| 4133 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>()); | 4174 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>()); |
| 4134 return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); | 4175 return scope.Escape(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); |
| 4135 } | 4176 } |
| 4136 | 4177 |
| 4137 | 4178 |
| 4138 Local<v8::Value> Function::Call(v8::Handle<v8::Value> recv, int argc, | 4179 Local<v8::Value> Function::Call(v8::Handle<v8::Value> recv, int argc, |
| 4139 v8::Handle<v8::Value> argv[]) { | 4180 v8::Handle<v8::Value> argv[]) { |
| 4140 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 4181 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 4141 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>()); | 4182 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>()); |
| 4142 LOG_API(isolate, "Function::Call"); | 4183 LOG_API(isolate, "Function::Call"); |
| 4143 ENTER_V8(isolate); | 4184 ENTER_V8(isolate); |
| 4144 i::Logger::TimerEventScope timer_scope( | 4185 i::Logger::TimerEventScope timer_scope( |
| (...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5276 | 5317 |
| 5277 // Restore the access check info on the global template. | 5318 // Restore the access check info on the global template. |
| 5278 if (!global_template.IsEmpty()) { | 5319 if (!global_template.IsEmpty()) { |
| 5279 ASSERT(!global_constructor.is_null()); | 5320 ASSERT(!global_constructor.is_null()); |
| 5280 ASSERT(!proxy_constructor.is_null()); | 5321 ASSERT(!proxy_constructor.is_null()); |
| 5281 global_constructor->set_access_check_info( | 5322 global_constructor->set_access_check_info( |
| 5282 proxy_constructor->access_check_info()); | 5323 proxy_constructor->access_check_info()); |
| 5283 global_constructor->set_needs_access_check( | 5324 global_constructor->set_needs_access_check( |
| 5284 proxy_constructor->needs_access_check()); | 5325 proxy_constructor->needs_access_check()); |
| 5285 } | 5326 } |
| 5286 isolate->runtime_profiler()->Reset(); | |
| 5287 } | 5327 } |
| 5288 // Leave V8. | 5328 // Leave V8. |
| 5289 | 5329 |
| 5290 return env; | 5330 return env; |
| 5291 } | 5331 } |
| 5292 | 5332 |
| 5293 Local<Context> v8::Context::New( | 5333 Local<Context> v8::Context::New( |
| 5294 v8::Isolate* external_isolate, | 5334 v8::Isolate* external_isolate, |
| 5295 v8::ExtensionConfiguration* extensions, | 5335 v8::ExtensionConfiguration* extensions, |
| 5296 v8::Handle<ObjectTemplate> global_template, | 5336 v8::Handle<ObjectTemplate> global_template, |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5645 ASSERT(parent->IsSlicedString()); | 5685 ASSERT(parent->IsSlicedString()); |
| 5646 i::Handle<i::SlicedString> slice = i::Handle<i::SlicedString>::cast(parent); | 5686 i::Handle<i::SlicedString> slice = i::Handle<i::SlicedString>::cast(parent); |
| 5647 slice->set_parent(*external); | 5687 slice->set_parent(*external); |
| 5648 slice->set_offset(0); | 5688 slice->set_offset(0); |
| 5649 } | 5689 } |
| 5650 return true; | 5690 return true; |
| 5651 } | 5691 } |
| 5652 | 5692 |
| 5653 | 5693 |
| 5654 Local<String> v8::String::NewExternal( | 5694 Local<String> v8::String::NewExternal( |
| 5695 Isolate* isolate, |
| 5696 v8::String::ExternalStringResource* resource) { |
| 5697 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5698 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); |
| 5699 LOG_API(i_isolate, "String::NewExternal"); |
| 5700 ENTER_V8(i_isolate); |
| 5701 CHECK(resource && resource->data()); |
| 5702 i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource); |
| 5703 i_isolate->heap()->external_string_table()->AddString(*result); |
| 5704 return Utils::ToLocal(result); |
| 5705 } |
| 5706 |
| 5707 |
| 5708 Local<String> v8::String::NewExternal( |
| 5655 v8::String::ExternalStringResource* resource) { | 5709 v8::String::ExternalStringResource* resource) { |
| 5656 i::Isolate* isolate = i::Isolate::Current(); | 5710 return NewExternal(Isolate::GetCurrent(), resource); |
| 5657 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); | |
| 5658 LOG_API(isolate, "String::NewExternal"); | |
| 5659 ENTER_V8(isolate); | |
| 5660 CHECK(resource && resource->data()); | |
| 5661 i::Handle<i::String> result = NewExternalStringHandle(isolate, resource); | |
| 5662 isolate->heap()->external_string_table()->AddString(*result); | |
| 5663 return Utils::ToLocal(result); | |
| 5664 } | 5711 } |
| 5665 | 5712 |
| 5666 | 5713 |
| 5667 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { | 5714 bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { |
| 5668 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5715 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 5669 i::Isolate* isolate = obj->GetIsolate(); | 5716 i::Isolate* isolate = obj->GetIsolate(); |
| 5670 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5717 if (i::StringShape(*obj).IsExternalTwoByte()) { |
| 5671 return false; // Already an external string. | 5718 return false; // Already an external string. |
| 5672 } | 5719 } |
| 5673 ENTER_V8(isolate); | 5720 ENTER_V8(isolate); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5685 // We do not allow external strings in the old pointer space. Instead of | 5732 // We do not allow external strings in the old pointer space. Instead of |
| 5686 // converting the string in-place, we keep the cons/sliced string and | 5733 // converting the string in-place, we keep the cons/sliced string and |
| 5687 // point it to a newly-allocated external string. | 5734 // point it to a newly-allocated external string. |
| 5688 external = NewExternalStringHandle(isolate, resource); | 5735 external = NewExternalStringHandle(isolate, resource); |
| 5689 result = RedirectToExternalString(isolate, obj, external); | 5736 result = RedirectToExternalString(isolate, obj, external); |
| 5690 } else { | 5737 } else { |
| 5691 result = obj->MakeExternal(resource); | 5738 result = obj->MakeExternal(resource); |
| 5692 external = obj; | 5739 external = obj; |
| 5693 } | 5740 } |
| 5694 | 5741 |
| 5695 ASSERT(external->IsExternalString()); | 5742 if (result) { |
| 5696 if (result && !external->IsInternalizedString()) { | 5743 ASSERT(external->IsExternalString()); |
| 5697 isolate->heap()->external_string_table()->AddString(*external); | 5744 isolate->heap()->external_string_table()->AddString(*external); |
| 5698 } | 5745 } |
| 5699 return result; | 5746 return result; |
| 5700 } | 5747 } |
| 5701 | 5748 |
| 5702 | 5749 |
| 5703 Local<String> v8::String::NewExternal( | 5750 Local<String> v8::String::NewExternal( |
| 5751 Isolate* isolate, |
| 5752 v8::String::ExternalAsciiStringResource* resource) { |
| 5753 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5754 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); |
| 5755 LOG_API(i_isolate, "String::NewExternal"); |
| 5756 ENTER_V8(i_isolate); |
| 5757 CHECK(resource && resource->data()); |
| 5758 i::Handle<i::String> result = |
| 5759 NewExternalAsciiStringHandle(i_isolate, resource); |
| 5760 i_isolate->heap()->external_string_table()->AddString(*result); |
| 5761 return Utils::ToLocal(result); |
| 5762 } |
| 5763 |
| 5764 |
| 5765 Local<String> v8::String::NewExternal( |
| 5704 v8::String::ExternalAsciiStringResource* resource) { | 5766 v8::String::ExternalAsciiStringResource* resource) { |
| 5705 i::Isolate* isolate = i::Isolate::Current(); | 5767 return NewExternal(Isolate::GetCurrent(), resource); |
| 5706 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); | |
| 5707 LOG_API(isolate, "String::NewExternal"); | |
| 5708 ENTER_V8(isolate); | |
| 5709 CHECK(resource && resource->data()); | |
| 5710 i::Handle<i::String> result = NewExternalAsciiStringHandle(isolate, resource); | |
| 5711 isolate->heap()->external_string_table()->AddString(*result); | |
| 5712 return Utils::ToLocal(result); | |
| 5713 } | 5768 } |
| 5714 | 5769 |
| 5715 | 5770 |
| 5716 bool v8::String::MakeExternal( | 5771 bool v8::String::MakeExternal( |
| 5717 v8::String::ExternalAsciiStringResource* resource) { | 5772 v8::String::ExternalAsciiStringResource* resource) { |
| 5718 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5773 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 5719 i::Isolate* isolate = obj->GetIsolate(); | 5774 i::Isolate* isolate = obj->GetIsolate(); |
| 5720 if (i::StringShape(*obj).IsExternalTwoByte()) { | 5775 if (i::StringShape(*obj).IsExternalTwoByte()) { |
| 5721 return false; // Already an external string. | 5776 return false; // Already an external string. |
| 5722 } | 5777 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5735 // We do not allow external strings in the old pointer space. Instead of | 5790 // We do not allow external strings in the old pointer space. Instead of |
| 5736 // converting the string in-place, we keep the cons/sliced string and | 5791 // converting the string in-place, we keep the cons/sliced string and |
| 5737 // point it to a newly-allocated external string. | 5792 // point it to a newly-allocated external string. |
| 5738 external = NewExternalAsciiStringHandle(isolate, resource); | 5793 external = NewExternalAsciiStringHandle(isolate, resource); |
| 5739 result = RedirectToExternalString(isolate, obj, external); | 5794 result = RedirectToExternalString(isolate, obj, external); |
| 5740 } else { | 5795 } else { |
| 5741 result = obj->MakeExternal(resource); | 5796 result = obj->MakeExternal(resource); |
| 5742 external = obj; | 5797 external = obj; |
| 5743 } | 5798 } |
| 5744 | 5799 |
| 5745 ASSERT(external->IsExternalString()); | 5800 if (result) { |
| 5746 if (result && !external->IsInternalizedString()) { | 5801 ASSERT(external->IsExternalString()); |
| 5747 isolate->heap()->external_string_table()->AddString(*external); | 5802 isolate->heap()->external_string_table()->AddString(*external); |
| 5748 } | 5803 } |
| 5749 return result; | 5804 return result; |
| 5750 } | 5805 } |
| 5751 | 5806 |
| 5752 | 5807 |
| 5753 bool v8::String::CanMakeExternal() { | 5808 bool v8::String::CanMakeExternal() { |
| 5754 if (!internal::FLAG_clever_optimizations) return false; | 5809 if (!internal::FLAG_clever_optimizations) return false; |
| 5755 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5810 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 5756 i::Isolate* isolate = obj->GetIsolate(); | 5811 i::Isolate* isolate = obj->GetIsolate(); |
| 5757 | 5812 |
| 5758 // TODO(yangguo): Externalizing sliced/cons strings allocates. | 5813 // TODO(yangguo): Externalizing sliced/cons strings allocates. |
| 5759 // This rule can be removed when all code that can | 5814 // This rule can be removed when all code that can |
| 5760 // trigger an access check is handlified and therefore GC safe. | 5815 // trigger an access check is handlified and therefore GC safe. |
| 5761 if (isolate->heap()->old_pointer_space()->Contains(*obj)) return false; | 5816 if (isolate->heap()->old_pointer_space()->Contains(*obj)) return false; |
| 5762 | 5817 |
| 5763 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; | 5818 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; |
| 5764 int size = obj->Size(); // Byte size of the original string. | 5819 int size = obj->Size(); // Byte size of the original string. |
| 5765 if (size < i::ExternalString::kShortSize) return false; | 5820 if (size < i::ExternalString::kShortSize) return false; |
| 5766 i::StringShape shape(*obj); | 5821 i::StringShape shape(*obj); |
| 5767 return !shape.IsExternal(); | 5822 return !shape.IsExternal(); |
| 5768 } | 5823 } |
| 5769 | 5824 |
| 5770 | 5825 |
| 5826 Local<v8::Object> v8::Object::New(Isolate* isolate) { |
| 5827 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5828 EnsureInitializedForIsolate(i_isolate, "v8::Object::New()"); |
| 5829 LOG_API(i_isolate, "Object::New"); |
| 5830 ENTER_V8(i_isolate); |
| 5831 i::Handle<i::JSObject> obj = |
| 5832 i_isolate->factory()->NewJSObject(i_isolate->object_function()); |
| 5833 return Utils::ToLocal(obj); |
| 5834 } |
| 5835 |
| 5836 |
| 5771 Local<v8::Object> v8::Object::New() { | 5837 Local<v8::Object> v8::Object::New() { |
| 5772 i::Isolate* isolate = i::Isolate::Current(); | 5838 return New(Isolate::GetCurrent()); |
| 5773 EnsureInitializedForIsolate(isolate, "v8::Object::New()"); | 5839 } |
| 5774 LOG_API(isolate, "Object::New"); | 5840 |
| 5775 ENTER_V8(isolate); | 5841 |
| 5776 i::Handle<i::JSObject> obj = | 5842 Local<v8::Value> v8::NumberObject::New(Isolate* isolate, double value) { |
| 5777 isolate->factory()->NewJSObject(isolate->object_function()); | 5843 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5844 EnsureInitializedForIsolate(i_isolate, "v8::NumberObject::New()"); |
| 5845 LOG_API(i_isolate, "NumberObject::New"); |
| 5846 ENTER_V8(i_isolate); |
| 5847 i::Handle<i::Object> number = i_isolate->factory()->NewNumber(value); |
| 5848 i::Handle<i::Object> obj = i_isolate->factory()->ToObject(number); |
| 5778 return Utils::ToLocal(obj); | 5849 return Utils::ToLocal(obj); |
| 5779 } | 5850 } |
| 5780 | 5851 |
| 5781 | 5852 |
| 5782 Local<v8::Value> v8::NumberObject::New(double value) { | 5853 Local<v8::Value> v8::NumberObject::New(double value) { |
| 5783 i::Isolate* isolate = i::Isolate::Current(); | 5854 return New(Isolate::GetCurrent(), value); |
| 5784 EnsureInitializedForIsolate(isolate, "v8::NumberObject::New()"); | |
| 5785 LOG_API(isolate, "NumberObject::New"); | |
| 5786 ENTER_V8(isolate); | |
| 5787 i::Handle<i::Object> number = isolate->factory()->NewNumber(value); | |
| 5788 i::Handle<i::Object> obj = isolate->factory()->ToObject(number); | |
| 5789 return Utils::ToLocal(obj); | |
| 5790 } | 5855 } |
| 5791 | 5856 |
| 5792 | 5857 |
| 5793 double v8::NumberObject::ValueOf() const { | 5858 double v8::NumberObject::ValueOf() const { |
| 5794 i::Isolate* isolate = i::Isolate::Current(); | 5859 i::Isolate* isolate = i::Isolate::Current(); |
| 5795 LOG_API(isolate, "NumberObject::NumberValue"); | 5860 LOG_API(isolate, "NumberObject::NumberValue"); |
| 5796 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5861 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 5797 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5862 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
| 5798 return jsvalue->value()->Number(); | 5863 return jsvalue->value()->Number(); |
| 5799 } | 5864 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5857 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { | 5922 Local<v8::Symbol> v8::SymbolObject::ValueOf() const { |
| 5858 i::Isolate* isolate = i::Isolate::Current(); | 5923 i::Isolate* isolate = i::Isolate::Current(); |
| 5859 LOG_API(isolate, "SymbolObject::SymbolValue"); | 5924 LOG_API(isolate, "SymbolObject::SymbolValue"); |
| 5860 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5925 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 5861 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); | 5926 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); |
| 5862 return Utils::ToLocal( | 5927 return Utils::ToLocal( |
| 5863 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); | 5928 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value()))); |
| 5864 } | 5929 } |
| 5865 | 5930 |
| 5866 | 5931 |
| 5932 Local<v8::Value> v8::Date::New(Isolate* isolate, double time) { |
| 5933 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5934 EnsureInitializedForIsolate(i_isolate, "v8::Date::New()"); |
| 5935 LOG_API(i_isolate, "Date::New"); |
| 5936 if (std::isnan(time)) { |
| 5937 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. |
| 5938 time = i::OS::nan_value(); |
| 5939 } |
| 5940 ENTER_V8(i_isolate); |
| 5941 EXCEPTION_PREAMBLE(i_isolate); |
| 5942 i::Handle<i::Object> obj = |
| 5943 i::Execution::NewDate(i_isolate, time, &has_pending_exception); |
| 5944 EXCEPTION_BAILOUT_CHECK(i_isolate, Local<v8::Value>()); |
| 5945 return Utils::ToLocal(obj); |
| 5946 } |
| 5947 |
| 5948 |
| 5867 Local<v8::Value> v8::Date::New(double time) { | 5949 Local<v8::Value> v8::Date::New(double time) { |
| 5868 i::Isolate* isolate = i::Isolate::Current(); | 5950 return New(Isolate::GetCurrent(), time); |
| 5869 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); | |
| 5870 LOG_API(isolate, "Date::New"); | |
| 5871 if (std::isnan(time)) { | |
| 5872 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | |
| 5873 time = i::OS::nan_value(); | |
| 5874 } | |
| 5875 ENTER_V8(isolate); | |
| 5876 EXCEPTION_PREAMBLE(isolate); | |
| 5877 i::Handle<i::Object> obj = | |
| 5878 i::Execution::NewDate(isolate, time, &has_pending_exception); | |
| 5879 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Value>()); | |
| 5880 return Utils::ToLocal(obj); | |
| 5881 } | 5951 } |
| 5882 | 5952 |
| 5883 | 5953 |
| 5884 double v8::Date::ValueOf() const { | 5954 double v8::Date::ValueOf() const { |
| 5885 i::Isolate* isolate = i::Isolate::Current(); | 5955 i::Isolate* isolate = i::Isolate::Current(); |
| 5886 LOG_API(isolate, "Date::NumberValue"); | 5956 LOG_API(isolate, "Date::NumberValue"); |
| 5887 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 5957 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 5888 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); | 5958 i::Handle<i::JSDate> jsdate = i::Handle<i::JSDate>::cast(obj); |
| 5889 return jsdate->value()->Number(); | 5959 return jsdate->value()->Number(); |
| 5890 } | 5960 } |
| 5891 | 5961 |
| 5892 | 5962 |
| 5893 void v8::Date::DateTimeConfigurationChangeNotification() { | 5963 void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) { |
| 5894 i::Isolate* isolate = i::Isolate::Current(); | 5964 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5895 ON_BAILOUT(isolate, "v8::Date::DateTimeConfigurationChangeNotification()", | 5965 ON_BAILOUT(i_isolate, "v8::Date::DateTimeConfigurationChangeNotification()", |
| 5896 return); | 5966 return); |
| 5897 LOG_API(isolate, "Date::DateTimeConfigurationChangeNotification"); | 5967 LOG_API(i_isolate, "Date::DateTimeConfigurationChangeNotification"); |
| 5898 ENTER_V8(isolate); | 5968 ENTER_V8(i_isolate); |
| 5899 | 5969 |
| 5900 isolate->date_cache()->ResetDateCache(); | 5970 i_isolate->date_cache()->ResetDateCache(); |
| 5901 | 5971 |
| 5902 i::HandleScope scope(isolate); | 5972 i::HandleScope scope(i_isolate); |
| 5903 // Get the function ResetDateCache (defined in date.js). | 5973 // Get the function ResetDateCache (defined in date.js). |
| 5904 i::Handle<i::String> func_name_str = | 5974 i::Handle<i::String> func_name_str = |
| 5905 isolate->factory()->InternalizeOneByteString( | 5975 i_isolate->factory()->InternalizeOneByteString( |
| 5906 STATIC_ASCII_VECTOR("ResetDateCache")); | 5976 STATIC_ASCII_VECTOR("ResetDateCache")); |
| 5907 i::MaybeObject* result = | 5977 i::MaybeObject* result = |
| 5908 isolate->js_builtins_object()->GetProperty(*func_name_str); | 5978 i_isolate->js_builtins_object()->GetProperty(*func_name_str); |
| 5909 i::Object* object_func; | 5979 i::Object* object_func; |
| 5910 if (!result->ToObject(&object_func)) { | 5980 if (!result->ToObject(&object_func)) { |
| 5911 return; | 5981 return; |
| 5912 } | 5982 } |
| 5913 | 5983 |
| 5914 if (object_func->IsJSFunction()) { | 5984 if (object_func->IsJSFunction()) { |
| 5915 i::Handle<i::JSFunction> func = | 5985 i::Handle<i::JSFunction> func = |
| 5916 i::Handle<i::JSFunction>(i::JSFunction::cast(object_func)); | 5986 i::Handle<i::JSFunction>(i::JSFunction::cast(object_func)); |
| 5917 | 5987 |
| 5918 // Call ResetDateCache(0 but expect no exceptions: | 5988 // Call ResetDateCache(0 but expect no exceptions: |
| 5919 bool caught_exception = false; | 5989 bool caught_exception = false; |
| 5920 i::Execution::TryCall(func, | 5990 i::Execution::TryCall(func, |
| 5921 isolate->js_builtins_object(), | 5991 i_isolate->js_builtins_object(), |
| 5922 0, | 5992 0, |
| 5923 NULL, | 5993 NULL, |
| 5924 &caught_exception); | 5994 &caught_exception); |
| 5925 } | 5995 } |
| 5926 } | 5996 } |
| 5927 | 5997 |
| 5928 | 5998 |
| 5999 void v8::Date::DateTimeConfigurationChangeNotification() { |
| 6000 DateTimeConfigurationChangeNotification(Isolate::GetCurrent()); |
| 6001 } |
| 6002 |
| 6003 |
| 5929 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { | 6004 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { |
| 5930 i::Isolate* isolate = i::Isolate::Current(); | 6005 i::Isolate* isolate = i::Isolate::Current(); |
| 5931 uint8_t flags_buf[3]; | 6006 uint8_t flags_buf[3]; |
| 5932 int num_flags = 0; | 6007 int num_flags = 0; |
| 5933 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; | 6008 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; |
| 5934 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; | 6009 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; |
| 5935 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; | 6010 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; |
| 5936 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); | 6011 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); |
| 5937 return isolate->factory()->InternalizeOneByteString( | 6012 return isolate->factory()->InternalizeOneByteString( |
| 5938 i::Vector<const uint8_t>(flags_buf, num_flags)); | 6013 i::Vector<const uint8_t>(flags_buf, num_flags)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5970 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE); | 6045 REGEXP_FLAG_ASSERT_EQ(kIgnoreCase, IGNORE_CASE); |
| 5971 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE); | 6046 REGEXP_FLAG_ASSERT_EQ(kMultiline, MULTILINE); |
| 5972 #undef REGEXP_FLAG_ASSERT_EQ | 6047 #undef REGEXP_FLAG_ASSERT_EQ |
| 5973 | 6048 |
| 5974 v8::RegExp::Flags v8::RegExp::GetFlags() const { | 6049 v8::RegExp::Flags v8::RegExp::GetFlags() const { |
| 5975 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); | 6050 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); |
| 5976 return static_cast<RegExp::Flags>(obj->GetFlags().value()); | 6051 return static_cast<RegExp::Flags>(obj->GetFlags().value()); |
| 5977 } | 6052 } |
| 5978 | 6053 |
| 5979 | 6054 |
| 6055 Local<v8::Array> v8::Array::New(Isolate* isolate, int length) { |
| 6056 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6057 EnsureInitializedForIsolate(i_isolate, "v8::Array::New()"); |
| 6058 LOG_API(i_isolate, "Array::New"); |
| 6059 ENTER_V8(i_isolate); |
| 6060 int real_length = length > 0 ? length : 0; |
| 6061 i::Handle<i::JSArray> obj = i_isolate->factory()->NewJSArray(real_length); |
| 6062 i::Handle<i::Object> length_obj = |
| 6063 i_isolate->factory()->NewNumberFromInt(real_length); |
| 6064 obj->set_length(*length_obj); |
| 6065 return Utils::ToLocal(obj); |
| 6066 } |
| 6067 |
| 6068 |
| 5980 Local<v8::Array> v8::Array::New(int length) { | 6069 Local<v8::Array> v8::Array::New(int length) { |
| 5981 i::Isolate* isolate = i::Isolate::Current(); | 6070 return New(Isolate::GetCurrent(), length); |
| 5982 EnsureInitializedForIsolate(isolate, "v8::Array::New()"); | |
| 5983 LOG_API(isolate, "Array::New"); | |
| 5984 ENTER_V8(isolate); | |
| 5985 int real_length = length > 0 ? length : 0; | |
| 5986 i::Handle<i::JSArray> obj = isolate->factory()->NewJSArray(real_length); | |
| 5987 i::Handle<i::Object> length_obj = | |
| 5988 isolate->factory()->NewNumberFromInt(real_length); | |
| 5989 obj->set_length(*length_obj); | |
| 5990 return Utils::ToLocal(obj); | |
| 5991 } | 6071 } |
| 5992 | 6072 |
| 5993 | 6073 |
| 5994 uint32_t v8::Array::Length() const { | 6074 uint32_t v8::Array::Length() const { |
| 5995 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); | 6075 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); |
| 5996 i::Object* length = obj->length(); | 6076 i::Object* length = obj->length(); |
| 5997 if (length->IsSmi()) { | 6077 if (length->IsSmi()) { |
| 5998 return i::Smi::cast(length)->value(); | 6078 return i::Smi::cast(length)->value(); |
| 5999 } else { | 6079 } else { |
| 6000 return static_cast<uint32_t>(length->Number()); | 6080 return static_cast<uint32_t>(length->Number()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6067 obj->Neuter(); | 6147 obj->Neuter(); |
| 6068 } | 6148 } |
| 6069 | 6149 |
| 6070 | 6150 |
| 6071 size_t v8::ArrayBuffer::ByteLength() const { | 6151 size_t v8::ArrayBuffer::ByteLength() const { |
| 6072 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 6152 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
| 6073 return static_cast<size_t>(obj->byte_length()->Number()); | 6153 return static_cast<size_t>(obj->byte_length()->Number()); |
| 6074 } | 6154 } |
| 6075 | 6155 |
| 6076 | 6156 |
| 6157 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, size_t byte_length) { |
| 6158 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6159 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(size_t)"); |
| 6160 LOG_API(i_isolate, "v8::ArrayBuffer::New(size_t)"); |
| 6161 ENTER_V8(i_isolate); |
| 6162 i::Handle<i::JSArrayBuffer> obj = |
| 6163 i_isolate->factory()->NewJSArrayBuffer(); |
| 6164 i::Runtime::SetupArrayBufferAllocatingData(i_isolate, obj, byte_length); |
| 6165 return Utils::ToLocal(obj); |
| 6166 } |
| 6167 |
| 6168 |
| 6077 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) { | 6169 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) { |
| 6078 i::Isolate* isolate = i::Isolate::Current(); | 6170 return New(Isolate::GetCurrent(), byte_length); |
| 6079 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(size_t)"); | 6171 } |
| 6080 LOG_API(isolate, "v8::ArrayBuffer::New(size_t)"); | 6172 |
| 6081 ENTER_V8(isolate); | 6173 |
| 6174 Local<ArrayBuffer> v8::ArrayBuffer::New(Isolate* isolate, void* data, |
| 6175 size_t byte_length) { |
| 6176 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6177 EnsureInitializedForIsolate(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
| 6178 LOG_API(i_isolate, "v8::ArrayBuffer::New(void*, size_t)"); |
| 6179 ENTER_V8(i_isolate); |
| 6082 i::Handle<i::JSArrayBuffer> obj = | 6180 i::Handle<i::JSArrayBuffer> obj = |
| 6083 isolate->factory()->NewJSArrayBuffer(); | 6181 i_isolate->factory()->NewJSArrayBuffer(); |
| 6084 i::Runtime::SetupArrayBufferAllocatingData(isolate, obj, byte_length); | 6182 i::Runtime::SetupArrayBuffer(i_isolate, obj, true, data, byte_length); |
| 6085 return Utils::ToLocal(obj); | 6183 return Utils::ToLocal(obj); |
| 6086 } | 6184 } |
| 6087 | 6185 |
| 6088 | 6186 |
| 6089 Local<ArrayBuffer> v8::ArrayBuffer::New(void* data, size_t byte_length) { | 6187 Local<ArrayBuffer> v8::ArrayBuffer::New(void* data, size_t byte_length) { |
| 6090 i::Isolate* isolate = i::Isolate::Current(); | 6188 return New(Isolate::GetCurrent(), data, byte_length); |
| 6091 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(void*, size_t)"); | |
| 6092 LOG_API(isolate, "v8::ArrayBuffer::New(void*, size_t)"); | |
| 6093 ENTER_V8(isolate); | |
| 6094 i::Handle<i::JSArrayBuffer> obj = | |
| 6095 isolate->factory()->NewJSArrayBuffer(); | |
| 6096 i::Runtime::SetupArrayBuffer(isolate, obj, true, data, byte_length); | |
| 6097 return Utils::ToLocal(obj); | |
| 6098 } | 6189 } |
| 6099 | 6190 |
| 6100 | 6191 |
| 6101 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { | 6192 Local<ArrayBuffer> v8::ArrayBufferView::Buffer() { |
| 6102 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); | 6193 i::Handle<i::JSArrayBufferView> obj = Utils::OpenHandle(this); |
| 6103 ASSERT(obj->buffer()->IsJSArrayBuffer()); | 6194 ASSERT(obj->buffer()->IsJSArrayBuffer()); |
| 6104 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); | 6195 i::Handle<i::JSArrayBuffer> buffer(i::JSArrayBuffer::cast(obj->buffer())); |
| 6105 return Utils::ToLocal(buffer); | 6196 return Utils::ToLocal(buffer); |
| 6106 } | 6197 } |
| 6107 | 6198 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6279 } | 6370 } |
| 6280 ENTER_V8(internal_isolate); | 6371 ENTER_V8(internal_isolate); |
| 6281 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 6372 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
| 6282 return Utils::NumberToLocal(result); | 6373 return Utils::NumberToLocal(result); |
| 6283 } | 6374 } |
| 6284 | 6375 |
| 6285 | 6376 |
| 6286 Local<Integer> v8::Integer::New(int32_t value) { | 6377 Local<Integer> v8::Integer::New(int32_t value) { |
| 6287 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 6378 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| 6288 EnsureInitializedForIsolate(isolate, "v8::Integer::New()"); | 6379 EnsureInitializedForIsolate(isolate, "v8::Integer::New()"); |
| 6289 return v8::Integer::New(value, reinterpret_cast<Isolate*>(isolate)); | 6380 return v8::Integer::New(reinterpret_cast<Isolate*>(isolate), value); |
| 6290 } | 6381 } |
| 6291 | 6382 |
| 6292 | 6383 |
| 6293 Local<Integer> Integer::NewFromUnsigned(uint32_t value) { | 6384 Local<Integer> Integer::NewFromUnsigned(uint32_t value) { |
| 6294 i::Isolate* isolate = i::Isolate::Current(); | 6385 i::Isolate* isolate = i::Isolate::Current(); |
| 6295 EnsureInitializedForIsolate(isolate, "v8::Integer::NewFromUnsigned()"); | 6386 EnsureInitializedForIsolate(isolate, "v8::Integer::NewFromUnsigned()"); |
| 6296 return Integer::NewFromUnsigned(value, reinterpret_cast<Isolate*>(isolate)); | 6387 return Integer::NewFromUnsigned(reinterpret_cast<Isolate*>(isolate), value); |
| 6297 } | 6388 } |
| 6298 | 6389 |
| 6299 | 6390 |
| 6300 Local<Integer> v8::Integer::New(int32_t value, Isolate* isolate) { | 6391 Local<Integer> v8::Integer::New(int32_t value, Isolate* isolate) { |
| 6392 return Integer::New(isolate, value); |
| 6393 } |
| 6394 |
| 6395 |
| 6396 Local<Integer> v8::Integer::NewFromUnsigned(uint32_t value, Isolate* isolate) { |
| 6397 return Integer::NewFromUnsigned(isolate, value); |
| 6398 } |
| 6399 |
| 6400 |
| 6401 Local<Integer> v8::Integer::New(Isolate* isolate, int32_t value) { |
| 6301 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6402 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6302 ASSERT(internal_isolate->IsInitialized()); | 6403 ASSERT(internal_isolate->IsInitialized()); |
| 6303 if (i::Smi::IsValid(value)) { | 6404 if (i::Smi::IsValid(value)) { |
| 6304 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value), | 6405 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value), |
| 6305 internal_isolate)); | 6406 internal_isolate)); |
| 6306 } | 6407 } |
| 6307 ENTER_V8(internal_isolate); | 6408 ENTER_V8(internal_isolate); |
| 6308 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 6409 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
| 6309 return Utils::IntegerToLocal(result); | 6410 return Utils::IntegerToLocal(result); |
| 6310 } | 6411 } |
| 6311 | 6412 |
| 6312 | 6413 |
| 6313 Local<Integer> v8::Integer::NewFromUnsigned(uint32_t value, Isolate* isolate) { | 6414 Local<Integer> v8::Integer::NewFromUnsigned(Isolate* isolate, uint32_t value) { |
| 6314 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6415 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6315 ASSERT(internal_isolate->IsInitialized()); | 6416 ASSERT(internal_isolate->IsInitialized()); |
| 6316 bool fits_into_int32_t = (value & (1 << 31)) == 0; | 6417 bool fits_into_int32_t = (value & (1 << 31)) == 0; |
| 6317 if (fits_into_int32_t) { | 6418 if (fits_into_int32_t) { |
| 6318 return Integer::New(static_cast<int32_t>(value), isolate); | 6419 return Integer::New(static_cast<int32_t>(value), isolate); |
| 6319 } | 6420 } |
| 6320 ENTER_V8(internal_isolate); | 6421 ENTER_V8(internal_isolate); |
| 6321 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); | 6422 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value); |
| 6322 return Utils::IntegerToLocal(result); | 6423 return Utils::IntegerToLocal(result); |
| 6323 } | 6424 } |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6966 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 7067 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
| 6967 return Utils::ToLocal(result); | 7068 return Utils::ToLocal(result); |
| 6968 } | 7069 } |
| 6969 | 7070 |
| 6970 | 7071 |
| 6971 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) { | 7072 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) { |
| 6972 i::Isolate* isolate = i::Isolate::Current(); | 7073 i::Isolate* isolate = i::Isolate::Current(); |
| 6973 if (!isolate->IsInitialized()) return Local<Value>(); | 7074 if (!isolate->IsInitialized()) return Local<Value>(); |
| 6974 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>()); | 7075 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>()); |
| 6975 ENTER_V8(isolate); | 7076 ENTER_V8(isolate); |
| 6976 v8::HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 7077 v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
| 6977 i::Debug* isolate_debug = isolate->debug(); | 7078 i::Debug* isolate_debug = isolate->debug(); |
| 6978 isolate_debug->Load(); | 7079 isolate_debug->Load(); |
| 6979 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); | 7080 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object()); |
| 6980 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString( | 7081 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString( |
| 6981 STATIC_ASCII_VECTOR("MakeMirror")); | 7082 STATIC_ASCII_VECTOR("MakeMirror")); |
| 6982 i::Handle<i::Object> fun_obj = i::GetProperty(isolate, debug, name); | 7083 i::Handle<i::Object> fun_obj = i::GetProperty(isolate, debug, name); |
| 6983 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); | 7084 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); |
| 6984 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); | 7085 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); |
| 6985 const int kArgc = 1; | 7086 const int kArgc = 1; |
| 6986 v8::Handle<v8::Value> argv[kArgc] = { obj }; | 7087 v8::Handle<v8::Value> argv[kArgc] = { obj }; |
| 6987 EXCEPTION_PREAMBLE(isolate); | 7088 EXCEPTION_PREAMBLE(isolate); |
| 6988 v8::Handle<v8::Value> result = v8_fun->Call(Utils::ToLocal(debug), | 7089 v8::Local<v8::Value> result = |
| 6989 kArgc, | 7090 v8_fun->Call(Utils::ToLocal(debug), kArgc, argv); |
| 6990 argv); | |
| 6991 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 7091 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
| 6992 return scope.Close(result); | 7092 return scope.Escape(result); |
| 6993 } | 7093 } |
| 6994 | 7094 |
| 6995 | 7095 |
| 6996 bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) { | 7096 bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) { |
| 6997 return i::Isolate::Current()->debugger()->StartAgent(name, port, | 7097 return i::Isolate::Current()->debugger()->StartAgent(name, port, |
| 6998 wait_for_connection); | 7098 wait_for_connection); |
| 6999 } | 7099 } |
| 7000 | 7100 |
| 7001 | 7101 |
| 7002 void Debug::DisableAgent() { | 7102 void Debug::DisableAgent() { |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7394 const HeapSnapshot* HeapProfiler::TakeHeapSnapshot( | 7494 const HeapSnapshot* HeapProfiler::TakeHeapSnapshot( |
| 7395 Handle<String> title, | 7495 Handle<String> title, |
| 7396 ActivityControl* control, | 7496 ActivityControl* control, |
| 7397 ObjectNameResolver* resolver) { | 7497 ObjectNameResolver* resolver) { |
| 7398 return reinterpret_cast<const HeapSnapshot*>( | 7498 return reinterpret_cast<const HeapSnapshot*>( |
| 7399 reinterpret_cast<i::HeapProfiler*>(this)->TakeSnapshot( | 7499 reinterpret_cast<i::HeapProfiler*>(this)->TakeSnapshot( |
| 7400 *Utils::OpenHandle(*title), control, resolver)); | 7500 *Utils::OpenHandle(*title), control, resolver)); |
| 7401 } | 7501 } |
| 7402 | 7502 |
| 7403 | 7503 |
| 7404 void HeapProfiler::StartTrackingHeapObjects() { | 7504 void HeapProfiler::StartTrackingHeapObjects(bool track_allocations) { |
| 7405 reinterpret_cast<i::HeapProfiler*>(this)->StartHeapObjectsTracking(); | 7505 reinterpret_cast<i::HeapProfiler*>(this)->StartHeapObjectsTracking( |
| 7506 track_allocations); |
| 7406 } | 7507 } |
| 7407 | 7508 |
| 7408 | 7509 |
| 7409 void HeapProfiler::StopTrackingHeapObjects() { | 7510 void HeapProfiler::StopTrackingHeapObjects() { |
| 7410 reinterpret_cast<i::HeapProfiler*>(this)->StopHeapObjectsTracking(); | 7511 reinterpret_cast<i::HeapProfiler*>(this)->StopHeapObjectsTracking(); |
| 7411 } | 7512 } |
| 7412 | 7513 |
| 7413 | 7514 |
| 7414 SnapshotObjectId HeapProfiler::GetHeapStats(OutputStream* stream) { | 7515 SnapshotObjectId HeapProfiler::GetHeapStats(OutputStream* stream) { |
| 7415 return reinterpret_cast<i::HeapProfiler*>(this)->PushHeapObjectsStats(stream); | 7516 return reinterpret_cast<i::HeapProfiler*>(this)->PushHeapObjectsStats(stream); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 7434 } | 7535 } |
| 7435 | 7536 |
| 7436 | 7537 |
| 7437 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, | 7538 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, |
| 7438 RetainedObjectInfo* info) { | 7539 RetainedObjectInfo* info) { |
| 7439 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info); | 7540 reinterpret_cast<i::HeapProfiler*>(this)->SetRetainedObjectInfo(id, info); |
| 7440 } | 7541 } |
| 7441 | 7542 |
| 7442 | 7543 |
| 7443 void HeapProfiler::StartRecordingHeapAllocations() { | 7544 void HeapProfiler::StartRecordingHeapAllocations() { |
| 7444 reinterpret_cast<i::HeapProfiler*>(this)->StartHeapAllocationsRecording(); | 7545 reinterpret_cast<i::HeapProfiler*>(this)->StartHeapObjectsTracking(true); |
| 7445 } | 7546 } |
| 7446 | 7547 |
| 7447 | 7548 |
| 7448 void HeapProfiler::StopRecordingHeapAllocations() { | 7549 void HeapProfiler::StopRecordingHeapAllocations() { |
| 7449 reinterpret_cast<i::HeapProfiler*>(this)->StopHeapAllocationsRecording(); | 7550 reinterpret_cast<i::HeapProfiler*>(this)->StopHeapObjectsTracking(); |
| 7450 } | 7551 } |
| 7451 | 7552 |
| 7452 | 7553 |
| 7453 v8::Testing::StressType internal::Testing::stress_type_ = | 7554 v8::Testing::StressType internal::Testing::stress_type_ = |
| 7454 v8::Testing::kStressTypeOpt; | 7555 v8::Testing::kStressTypeOpt; |
| 7455 | 7556 |
| 7456 | 7557 |
| 7457 void Testing::SetStressRunType(Testing::StressType type) { | 7558 void Testing::SetStressRunType(Testing::StressType type) { |
| 7458 internal::Testing::set_stress_type(type); | 7559 internal::Testing::set_stress_type(type); |
| 7459 } | 7560 } |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7684 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7785 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7685 Address callback_address = | 7786 Address callback_address = |
| 7686 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7787 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7687 VMState<EXTERNAL> state(isolate); | 7788 VMState<EXTERNAL> state(isolate); |
| 7688 ExternalCallbackScope call_scope(isolate, callback_address); | 7789 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7689 callback(info); | 7790 callback(info); |
| 7690 } | 7791 } |
| 7691 | 7792 |
| 7692 | 7793 |
| 7693 } } // namespace v8::internal | 7794 } } // namespace v8::internal |
| OLD | NEW |