OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 22 matching lines...) Expand all Loading... |
33 #include "compiler.h" | 33 #include "compiler.h" |
34 #include "debug.h" | 34 #include "debug.h" |
35 #include "execution.h" | 35 #include "execution.h" |
36 #include "global-handles.h" | 36 #include "global-handles.h" |
37 #include "heap-profiler.h" | 37 #include "heap-profiler.h" |
38 #include "messages.h" | 38 #include "messages.h" |
39 #include "platform.h" | 39 #include "platform.h" |
40 #include "profile-generator-inl.h" | 40 #include "profile-generator-inl.h" |
41 #include "serialize.h" | 41 #include "serialize.h" |
42 #include "snapshot.h" | 42 #include "snapshot.h" |
43 #include "top.h" | |
44 #include "utils.h" | 43 #include "utils.h" |
45 #include "v8threads.h" | 44 #include "v8threads.h" |
46 #include "version.h" | 45 #include "version.h" |
47 | 46 |
48 #include "../include/v8-profiler.h" | 47 #include "../include/v8-profiler.h" |
49 | 48 |
50 #define LOG_API(expr) LOG(ApiEntryCall(expr)) | 49 #define LOG_API(expr) LOG(ApiEntryCall(expr)) |
51 | 50 |
52 #ifdef ENABLE_VMSTATE_TRACKING | 51 #ifdef ENABLE_VMSTATE_TRACKING |
53 #define ENTER_V8 i::VMState __state__(i::OTHER) | 52 #define ENTER_V8 i::VMState __state__(i::OTHER) |
54 #define LEAVE_V8 i::VMState __state__(i::EXTERNAL) | 53 #define LEAVE_V8 i::VMState __state__(i::EXTERNAL) |
55 #else | 54 #else |
56 #define ENTER_V8 ((void) 0) | 55 #define ENTER_V8 ((void) 0) |
57 #define LEAVE_V8 ((void) 0) | 56 #define LEAVE_V8 ((void) 0) |
58 #endif | 57 #endif |
59 | 58 |
60 namespace v8 { | 59 namespace v8 { |
61 | 60 |
62 #define ON_BAILOUT(location, code) \ | 61 #define ON_BAILOUT(location, code) \ |
63 if (IsDeadCheck(location) || v8::V8::IsExecutionTerminating()) { \ | 62 if (IsDeadCheck(location) || v8::V8::IsExecutionTerminating()) { \ |
64 code; \ | 63 code; \ |
65 UNREACHABLE(); \ | 64 UNREACHABLE(); \ |
66 } | 65 } |
67 | 66 |
68 | 67 |
69 #define EXCEPTION_PREAMBLE() \ | 68 #define EXCEPTION_PREAMBLE() \ |
70 i::Isolate* isolate = i::Isolate::Current(); \ | 69 i::Isolate* isolate = i::Isolate::Current(); \ |
71 isolate->handle_scope_implementer()->IncrementCallDepth(); \ | 70 isolate->handle_scope_implementer()->IncrementCallDepth(); \ |
72 ASSERT(!i::Top::external_caught_exception()); \ | 71 ASSERT(!isolate->external_caught_exception()); \ |
73 bool has_pending_exception = false | 72 bool has_pending_exception = false |
74 | 73 |
75 | 74 |
76 #define EXCEPTION_BAILOUT_CHECK(value) \ | 75 #define EXCEPTION_BAILOUT_CHECK(value) \ |
77 do { \ | 76 do { \ |
78 i::HandleScopeImplementer* handle_scope_implementer = \ | 77 i::HandleScopeImplementer* handle_scope_implementer = \ |
79 isolate->handle_scope_implementer(); \ | 78 isolate->handle_scope_implementer(); \ |
80 handle_scope_implementer->DecrementCallDepth(); \ | 79 handle_scope_implementer->DecrementCallDepth(); \ |
81 if (has_pending_exception) { \ | 80 if (has_pending_exception) { \ |
82 if (handle_scope_implementer->CallDepthIsZero() && \ | 81 if (handle_scope_implementer->CallDepthIsZero() && \ |
83 i::Top::is_out_of_memory()) { \ | 82 i::Isolate::Current()->is_out_of_memory()) { \ |
84 if (!handle_scope_implementer->ignore_out_of_memory()) \ | 83 if (!handle_scope_implementer->ignore_out_of_memory()) \ |
85 i::V8::FatalProcessOutOfMemory(NULL); \ | 84 i::V8::FatalProcessOutOfMemory(NULL); \ |
86 } \ | 85 } \ |
87 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ | 86 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ |
88 i::Top::OptionalRescheduleException(call_depth_is_zero); \ | 87 i::Isolate::Current()->OptionalRescheduleException(call_depth_is_zero); \ |
89 return value; \ | 88 return value; \ |
90 } \ | 89 } \ |
91 } while (false) | 90 } while (false) |
92 | 91 |
93 | 92 |
94 #define API_ENTRY_CHECK(msg) \ | 93 #define API_ENTRY_CHECK(msg) \ |
95 do { \ | 94 do { \ |
96 if (v8::Locker::IsActive()) { \ | 95 if (v8::Locker::IsActive()) { \ |
97 ApiCheck(i::ThreadManager::IsLockedByCurrentThread(), \ | 96 ApiCheck(i::ThreadManager::IsLockedByCurrentThread(), \ |
98 msg, \ | 97 msg, \ |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags); | 305 i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags); |
307 } | 306 } |
308 | 307 |
309 | 308 |
310 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) { | 309 v8::Handle<Value> ThrowException(v8::Handle<v8::Value> value) { |
311 if (IsDeadCheck("v8::ThrowException()")) return v8::Handle<Value>(); | 310 if (IsDeadCheck("v8::ThrowException()")) return v8::Handle<Value>(); |
312 ENTER_V8; | 311 ENTER_V8; |
313 // If we're passed an empty handle, we throw an undefined exception | 312 // If we're passed an empty handle, we throw an undefined exception |
314 // to deal more gracefully with out of memory situations. | 313 // to deal more gracefully with out of memory situations. |
315 if (value.IsEmpty()) { | 314 if (value.IsEmpty()) { |
316 i::Top::ScheduleThrow(HEAP->undefined_value()); | 315 i::Isolate::Current()->ScheduleThrow(HEAP->undefined_value()); |
317 } else { | 316 } else { |
318 i::Top::ScheduleThrow(*Utils::OpenHandle(*value)); | 317 i::Isolate::Current()->ScheduleThrow(*Utils::OpenHandle(*value)); |
319 } | 318 } |
320 return v8::Undefined(); | 319 return v8::Undefined(); |
321 } | 320 } |
322 | 321 |
323 | 322 |
324 RegisteredExtension* RegisteredExtension::first_extension_ = NULL; | 323 RegisteredExtension* RegisteredExtension::first_extension_ = NULL; |
325 | 324 |
326 | 325 |
327 RegisteredExtension::RegisteredExtension(Extension* extension) | 326 RegisteredExtension::RegisteredExtension(Extension* extension) |
328 : extension_(extension), state_(UNVISITED) { } | 327 : extension_(extension), state_(UNVISITED) { } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 | 468 |
470 | 469 |
471 void Context::Enter() { | 470 void Context::Enter() { |
472 if (IsDeadCheck("v8::Context::Enter()")) return; | 471 if (IsDeadCheck("v8::Context::Enter()")) return; |
473 ENTER_V8; | 472 ENTER_V8; |
474 i::Handle<i::Context> env = Utils::OpenHandle(this); | 473 i::Handle<i::Context> env = Utils::OpenHandle(this); |
475 // TODO(isolates): Context should have a pointer to isolate. | 474 // TODO(isolates): Context should have a pointer to isolate. |
476 i::Isolate* isolate = i::Isolate::Current(); | 475 i::Isolate* isolate = i::Isolate::Current(); |
477 isolate->handle_scope_implementer()->EnterContext(env); | 476 isolate->handle_scope_implementer()->EnterContext(env); |
478 | 477 |
479 isolate->handle_scope_implementer()->SaveContext(i::Top::context()); | 478 isolate->handle_scope_implementer()->SaveContext(isolate->context()); |
480 i::Top::set_context(*env); | 479 isolate->set_context(*env); |
481 } | 480 } |
482 | 481 |
483 | 482 |
484 void Context::Exit() { | 483 void Context::Exit() { |
485 if (!i::V8::IsRunning()) return; | 484 if (!i::V8::IsRunning()) return; |
486 // TODO(isolates): Context should have a pointer to isolate. | 485 // TODO(isolates): Context should have a pointer to isolate. |
487 i::Isolate* isolate = i::Isolate::Current(); | 486 i::Isolate* isolate = i::Isolate::Current(); |
488 | 487 |
489 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveLastContext(), | 488 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveLastContext(), |
490 "v8::Context::Exit()", | 489 "v8::Context::Exit()", |
491 "Cannot exit non-entered context")) { | 490 "Cannot exit non-entered context")) { |
492 return; | 491 return; |
493 } | 492 } |
494 | 493 |
495 // Content of 'last_context' could be NULL. | 494 // Content of 'last_context' could be NULL. |
496 i::Context* last_context = | 495 i::Context* last_context = |
497 isolate->handle_scope_implementer()->RestoreContext(); | 496 isolate->handle_scope_implementer()->RestoreContext(); |
498 i::Top::set_context(last_context); | 497 isolate->set_context(last_context); |
499 } | 498 } |
500 | 499 |
501 | 500 |
502 void Context::SetData(v8::Handle<String> data) { | 501 void Context::SetData(v8::Handle<String> data) { |
503 if (IsDeadCheck("v8::Context::SetData()")) return; | 502 if (IsDeadCheck("v8::Context::SetData()")) return; |
504 ENTER_V8; | 503 ENTER_V8; |
505 { | 504 { |
506 HandleScope scope; | 505 HandleScope scope; |
507 i::Handle<i::Context> env = Utils::OpenHandle(this); | 506 i::Handle<i::Context> env = Utils::OpenHandle(this); |
508 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data); | 507 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data); |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 ON_BAILOUT("v8::Script::Compile()", return Local<Script>()); | 1207 ON_BAILOUT("v8::Script::Compile()", return Local<Script>()); |
1209 LOG_API("Script::Compile"); | 1208 LOG_API("Script::Compile"); |
1210 ENTER_V8; | 1209 ENTER_V8; |
1211 Local<Script> generic = New(source, origin, pre_data, script_data); | 1210 Local<Script> generic = New(source, origin, pre_data, script_data); |
1212 if (generic.IsEmpty()) | 1211 if (generic.IsEmpty()) |
1213 return generic; | 1212 return generic; |
1214 i::Handle<i::Object> obj = Utils::OpenHandle(*generic); | 1213 i::Handle<i::Object> obj = Utils::OpenHandle(*generic); |
1215 i::Handle<i::SharedFunctionInfo> function = | 1214 i::Handle<i::SharedFunctionInfo> function = |
1216 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); | 1215 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); |
1217 i::Handle<i::JSFunction> result = | 1216 i::Handle<i::JSFunction> result = |
1218 i::Factory::NewFunctionFromSharedFunctionInfo(function, | 1217 i::Factory::NewFunctionFromSharedFunctionInfo( |
1219 i::Top::global_context()); | 1218 function, |
| 1219 i::Isolate::Current()->global_context()); |
1220 return Local<Script>(ToApi<Script>(result)); | 1220 return Local<Script>(ToApi<Script>(result)); |
1221 } | 1221 } |
1222 | 1222 |
1223 | 1223 |
1224 Local<Script> Script::Compile(v8::Handle<String> source, | 1224 Local<Script> Script::Compile(v8::Handle<String> source, |
1225 v8::Handle<Value> file_name, | 1225 v8::Handle<Value> file_name, |
1226 v8::Handle<String> script_data) { | 1226 v8::Handle<String> script_data) { |
1227 ScriptOrigin origin(file_name); | 1227 ScriptOrigin origin(file_name); |
1228 return Compile(source, &origin, 0, script_data); | 1228 return Compile(source, &origin, 0, script_data); |
1229 } | 1229 } |
1230 | 1230 |
1231 | 1231 |
1232 Local<Value> Script::Run() { | 1232 Local<Value> Script::Run() { |
1233 ON_BAILOUT("v8::Script::Run()", return Local<Value>()); | 1233 ON_BAILOUT("v8::Script::Run()", return Local<Value>()); |
1234 LOG_API("Script::Run"); | 1234 LOG_API("Script::Run"); |
1235 ENTER_V8; | 1235 ENTER_V8; |
1236 i::Object* raw_result = NULL; | 1236 i::Object* raw_result = NULL; |
1237 { | 1237 { |
1238 HandleScope scope; | 1238 HandleScope scope; |
1239 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 1239 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
1240 i::Handle<i::JSFunction> fun; | 1240 i::Handle<i::JSFunction> fun; |
1241 if (obj->IsSharedFunctionInfo()) { | 1241 if (obj->IsSharedFunctionInfo()) { |
1242 i::Handle<i::SharedFunctionInfo> | 1242 i::Handle<i::SharedFunctionInfo> |
1243 function_info(i::SharedFunctionInfo::cast(*obj)); | 1243 function_info(i::SharedFunctionInfo::cast(*obj)); |
1244 fun = i::Factory::NewFunctionFromSharedFunctionInfo( | 1244 fun = i::Factory::NewFunctionFromSharedFunctionInfo( |
1245 function_info, i::Top::global_context()); | 1245 function_info, i::Isolate::Current()->global_context()); |
1246 } else { | 1246 } else { |
1247 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj)); | 1247 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj)); |
1248 } | 1248 } |
1249 EXCEPTION_PREAMBLE(); | 1249 EXCEPTION_PREAMBLE(); |
1250 i::Handle<i::Object> receiver(i::Top::context()->global_proxy()); | 1250 i::Handle<i::Object> receiver( |
| 1251 i::Isolate::Current()->context()->global_proxy()); |
1251 i::Handle<i::Object> result = | 1252 i::Handle<i::Object> result = |
1252 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); | 1253 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); |
1253 EXCEPTION_BAILOUT_CHECK(Local<Value>()); | 1254 EXCEPTION_BAILOUT_CHECK(Local<Value>()); |
1254 raw_result = *result; | 1255 raw_result = *result; |
1255 } | 1256 } |
1256 i::Handle<i::Object> result(raw_result); | 1257 i::Handle<i::Object> result(raw_result); |
1257 return Utils::ToLocal(result); | 1258 return Utils::ToLocal(result); |
1258 } | 1259 } |
1259 | 1260 |
1260 | 1261 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 i::Handle<i::Script> script(i::Script::cast(function_info->script())); | 1299 i::Handle<i::Script> script(i::Script::cast(function_info->script())); |
1299 script->set_data(*raw_data); | 1300 script->set_data(*raw_data); |
1300 } | 1301 } |
1301 } | 1302 } |
1302 | 1303 |
1303 | 1304 |
1304 // --- E x c e p t i o n s --- | 1305 // --- E x c e p t i o n s --- |
1305 | 1306 |
1306 | 1307 |
1307 v8::TryCatch::TryCatch() | 1308 v8::TryCatch::TryCatch() |
1308 : next_(i::Top::try_catch_handler_address()), | 1309 : next_(i::Isolate::Current()->try_catch_handler_address()), |
1309 exception_(HEAP->the_hole_value()), | 1310 exception_(HEAP->the_hole_value()), |
1310 message_(i::Smi::FromInt(0)), | 1311 message_(i::Smi::FromInt(0)), |
1311 is_verbose_(false), | 1312 is_verbose_(false), |
1312 can_continue_(true), | 1313 can_continue_(true), |
1313 capture_message_(true), | 1314 capture_message_(true), |
1314 rethrow_(false) { | 1315 rethrow_(false) { |
1315 i::Top::RegisterTryCatchHandler(this); | 1316 i::Isolate::Current()->RegisterTryCatchHandler(this); |
1316 } | 1317 } |
1317 | 1318 |
1318 | 1319 |
1319 v8::TryCatch::~TryCatch() { | 1320 v8::TryCatch::~TryCatch() { |
1320 if (rethrow_) { | 1321 if (rethrow_) { |
1321 v8::HandleScope scope; | 1322 v8::HandleScope scope; |
1322 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception()); | 1323 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception()); |
1323 i::Top::UnregisterTryCatchHandler(this); | 1324 i::Isolate::Current()->UnregisterTryCatchHandler(this); |
1324 v8::ThrowException(exc); | 1325 v8::ThrowException(exc); |
1325 } else { | 1326 } else { |
1326 i::Top::UnregisterTryCatchHandler(this); | 1327 i::Isolate::Current()->UnregisterTryCatchHandler(this); |
1327 } | 1328 } |
1328 } | 1329 } |
1329 | 1330 |
1330 | 1331 |
1331 bool v8::TryCatch::HasCaught() const { | 1332 bool v8::TryCatch::HasCaught() const { |
1332 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); | 1333 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); |
1333 } | 1334 } |
1334 | 1335 |
1335 | 1336 |
1336 bool v8::TryCatch::CanContinue() const { | 1337 bool v8::TryCatch::CanContinue() const { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 return scope.Close(Utils::ToLocal(data)); | 1444 return scope.Close(Utils::ToLocal(data)); |
1444 } | 1445 } |
1445 | 1446 |
1446 | 1447 |
1447 static i::Handle<i::Object> CallV8HeapFunction(const char* name, | 1448 static i::Handle<i::Object> CallV8HeapFunction(const char* name, |
1448 i::Handle<i::Object> recv, | 1449 i::Handle<i::Object> recv, |
1449 int argc, | 1450 int argc, |
1450 i::Object** argv[], | 1451 i::Object** argv[], |
1451 bool* has_pending_exception) { | 1452 bool* has_pending_exception) { |
1452 i::Handle<i::String> fmt_str = i::Factory::LookupAsciiSymbol(name); | 1453 i::Handle<i::String> fmt_str = i::Factory::LookupAsciiSymbol(name); |
1453 i::Object* object_fun = i::Top::builtins()->GetProperty(*fmt_str); | 1454 i::Object* object_fun = |
| 1455 i::Isolate::Current()->builtins()->GetProperty(*fmt_str); |
1454 i::Handle<i::JSFunction> fun = | 1456 i::Handle<i::JSFunction> fun = |
1455 i::Handle<i::JSFunction>(i::JSFunction::cast(object_fun)); | 1457 i::Handle<i::JSFunction>(i::JSFunction::cast(object_fun)); |
1456 i::Handle<i::Object> value = | 1458 i::Handle<i::Object> value = |
1457 i::Execution::Call(fun, recv, argc, argv, has_pending_exception); | 1459 i::Execution::Call(fun, recv, argc, argv, has_pending_exception); |
1458 return value; | 1460 return value; |
1459 } | 1461 } |
1460 | 1462 |
1461 | 1463 |
1462 static i::Handle<i::Object> CallV8HeapFunction(const char* name, | 1464 static i::Handle<i::Object> CallV8HeapFunction(const char* name, |
1463 i::Handle<i::Object> data, | 1465 i::Handle<i::Object> data, |
1464 bool* has_pending_exception) { | 1466 bool* has_pending_exception) { |
1465 i::Object** argv[1] = { data.location() }; | 1467 i::Object** argv[1] = { data.location() }; |
1466 return CallV8HeapFunction(name, | 1468 return CallV8HeapFunction(name, |
1467 i::Top::builtins(), | 1469 i::Isolate::Current()->builtins(), |
1468 1, | 1470 1, |
1469 argv, | 1471 argv, |
1470 has_pending_exception); | 1472 has_pending_exception); |
1471 } | 1473 } |
1472 | 1474 |
1473 | 1475 |
1474 int Message::GetLineNumber() const { | 1476 int Message::GetLineNumber() const { |
1475 ON_BAILOUT("v8::Message::GetLineNumber()", return kNoLineNumberInfo); | 1477 ON_BAILOUT("v8::Message::GetLineNumber()", return kNoLineNumberInfo); |
1476 ENTER_V8; | 1478 ENTER_V8; |
1477 HandleScope scope; | 1479 HandleScope scope; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result))); | 1550 return scope.Close(Utils::ToLocal(i::Handle<i::String>::cast(result))); |
1549 } else { | 1551 } else { |
1550 return Local<String>(); | 1552 return Local<String>(); |
1551 } | 1553 } |
1552 } | 1554 } |
1553 | 1555 |
1554 | 1556 |
1555 void Message::PrintCurrentStackTrace(FILE* out) { | 1557 void Message::PrintCurrentStackTrace(FILE* out) { |
1556 if (IsDeadCheck("v8::Message::PrintCurrentStackTrace()")) return; | 1558 if (IsDeadCheck("v8::Message::PrintCurrentStackTrace()")) return; |
1557 ENTER_V8; | 1559 ENTER_V8; |
1558 i::Top::PrintCurrentStackTrace(out); | 1560 i::Isolate::Current()->PrintCurrentStackTrace(out); |
1559 } | 1561 } |
1560 | 1562 |
1561 | 1563 |
1562 // --- S t a c k T r a c e --- | 1564 // --- S t a c k T r a c e --- |
1563 | 1565 |
1564 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { | 1566 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { |
1565 if (IsDeadCheck("v8::StackTrace::GetFrame()")) return Local<StackFrame>(); | 1567 if (IsDeadCheck("v8::StackTrace::GetFrame()")) return Local<StackFrame>(); |
1566 ENTER_V8; | 1568 ENTER_V8; |
1567 HandleScope scope; | 1569 HandleScope scope; |
1568 i::Handle<i::JSArray> self = Utils::OpenHandle(this); | 1570 i::Handle<i::JSArray> self = Utils::OpenHandle(this); |
(...skipping 13 matching lines...) Expand all Loading... |
1582 if (IsDeadCheck("v8::StackTrace::AsArray()")) Local<Array>(); | 1584 if (IsDeadCheck("v8::StackTrace::AsArray()")) Local<Array>(); |
1583 ENTER_V8; | 1585 ENTER_V8; |
1584 return Utils::ToLocal(Utils::OpenHandle(this)); | 1586 return Utils::ToLocal(Utils::OpenHandle(this)); |
1585 } | 1587 } |
1586 | 1588 |
1587 | 1589 |
1588 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit, | 1590 Local<StackTrace> StackTrace::CurrentStackTrace(int frame_limit, |
1589 StackTraceOptions options) { | 1591 StackTraceOptions options) { |
1590 if (IsDeadCheck("v8::StackTrace::CurrentStackTrace()")) Local<StackTrace>(); | 1592 if (IsDeadCheck("v8::StackTrace::CurrentStackTrace()")) Local<StackTrace>(); |
1591 ENTER_V8; | 1593 ENTER_V8; |
1592 return i::Top::CaptureCurrentStackTrace(frame_limit, options); | 1594 return i::Isolate::Current()->CaptureCurrentStackTrace(frame_limit, options); |
1593 } | 1595 } |
1594 | 1596 |
1595 | 1597 |
1596 // --- S t a c k F r a m e --- | 1598 // --- S t a c k F r a m e --- |
1597 | 1599 |
1598 int StackFrame::GetLineNumber() const { | 1600 int StackFrame::GetLineNumber() const { |
1599 if (IsDeadCheck("v8::StackFrame::GetLineNumber()")) { | 1601 if (IsDeadCheck("v8::StackFrame::GetLineNumber()")) { |
1600 return Message::kNoLineNumberInfo; | 1602 return Message::kNoLineNumberInfo; |
1601 } | 1603 } |
1602 ENTER_V8; | 1604 ENTER_V8; |
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3299 } | 3301 } |
3300 | 3302 |
3301 | 3303 |
3302 bool Context::HasOutOfMemoryException() { | 3304 bool Context::HasOutOfMemoryException() { |
3303 i::Handle<i::Context> env = Utils::OpenHandle(this); | 3305 i::Handle<i::Context> env = Utils::OpenHandle(this); |
3304 return env->has_out_of_memory(); | 3306 return env->has_out_of_memory(); |
3305 } | 3307 } |
3306 | 3308 |
3307 | 3309 |
3308 bool Context::InContext() { | 3310 bool Context::InContext() { |
3309 return i::Top::context() != NULL; | 3311 return i::Isolate::Current()->context() != NULL; |
3310 } | 3312 } |
3311 | 3313 |
3312 | 3314 |
3313 v8::Local<v8::Context> Context::GetEntered() { | 3315 v8::Local<v8::Context> Context::GetEntered() { |
3314 if (IsDeadCheck("v8::Context::GetEntered()")) return Local<Context>(); | 3316 if (IsDeadCheck("v8::Context::GetEntered()")) return Local<Context>(); |
3315 i::Handle<i::Object> last = | 3317 i::Handle<i::Object> last = |
3316 i::Isolate::Current()->handle_scope_implementer()->LastEnteredContext(); | 3318 i::Isolate::Current()->handle_scope_implementer()->LastEnteredContext(); |
3317 if (last.is_null()) return Local<Context>(); | 3319 if (last.is_null()) return Local<Context>(); |
3318 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last); | 3320 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last); |
3319 return Utils::ToLocal(context); | 3321 return Utils::ToLocal(context); |
3320 } | 3322 } |
3321 | 3323 |
3322 | 3324 |
3323 v8::Local<v8::Context> Context::GetCurrent() { | 3325 v8::Local<v8::Context> Context::GetCurrent() { |
3324 if (IsDeadCheck("v8::Context::GetCurrent()")) return Local<Context>(); | 3326 if (IsDeadCheck("v8::Context::GetCurrent()")) return Local<Context>(); |
3325 i::Handle<i::Object> current = i::Top::global_context(); | 3327 i::Handle<i::Object> current = i::Isolate::Current()->global_context(); |
3326 if (current.is_null()) return Local<Context>(); | 3328 if (current.is_null()) return Local<Context>(); |
3327 i::Handle<i::Context> context = i::Handle<i::Context>::cast(current); | 3329 i::Handle<i::Context> context = i::Handle<i::Context>::cast(current); |
3328 return Utils::ToLocal(context); | 3330 return Utils::ToLocal(context); |
3329 } | 3331 } |
3330 | 3332 |
3331 | 3333 |
3332 v8::Local<v8::Context> Context::GetCalling() { | 3334 v8::Local<v8::Context> Context::GetCalling() { |
3333 if (IsDeadCheck("v8::Context::GetCalling()")) return Local<Context>(); | 3335 if (IsDeadCheck("v8::Context::GetCalling()")) return Local<Context>(); |
3334 i::Handle<i::Object> calling = i::Top::GetCallingGlobalContext(); | 3336 i::Handle<i::Object> calling = |
| 3337 i::Isolate::Current()->GetCallingGlobalContext(); |
3335 if (calling.is_null()) return Local<Context>(); | 3338 if (calling.is_null()) return Local<Context>(); |
3336 i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling); | 3339 i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling); |
3337 return Utils::ToLocal(context); | 3340 return Utils::ToLocal(context); |
3338 } | 3341 } |
3339 | 3342 |
3340 | 3343 |
3341 v8::Local<v8::Object> Context::Global() { | 3344 v8::Local<v8::Object> Context::Global() { |
3342 if (IsDeadCheck("v8::Context::Global()")) return Local<v8::Object>(); | 3345 if (IsDeadCheck("v8::Context::Global()")) return Local<v8::Object>(); |
3343 i::Object** ctx = reinterpret_cast<i::Object**>(this); | 3346 i::Object** ctx = reinterpret_cast<i::Object**>(this); |
3344 i::Handle<i::Context> context = | 3347 i::Handle<i::Context> context = |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3623 i::StringShape shape(*obj); | 3626 i::StringShape shape(*obj); |
3624 return !shape.IsExternal(); | 3627 return !shape.IsExternal(); |
3625 } | 3628 } |
3626 | 3629 |
3627 | 3630 |
3628 Local<v8::Object> v8::Object::New() { | 3631 Local<v8::Object> v8::Object::New() { |
3629 EnsureInitialized("v8::Object::New()"); | 3632 EnsureInitialized("v8::Object::New()"); |
3630 LOG_API("Object::New"); | 3633 LOG_API("Object::New"); |
3631 ENTER_V8; | 3634 ENTER_V8; |
3632 i::Handle<i::JSObject> obj = | 3635 i::Handle<i::JSObject> obj = |
3633 i::Factory::NewJSObject(i::Top::object_function()); | 3636 i::Factory::NewJSObject(i::Isolate::Current()->object_function()); |
3634 return Utils::ToLocal(obj); | 3637 return Utils::ToLocal(obj); |
3635 } | 3638 } |
3636 | 3639 |
3637 | 3640 |
3638 Local<v8::Value> v8::Date::New(double time) { | 3641 Local<v8::Value> v8::Date::New(double time) { |
3639 EnsureInitialized("v8::Date::New()"); | 3642 EnsureInitialized("v8::Date::New()"); |
3640 LOG_API("Date::New"); | 3643 LOG_API("Date::New"); |
3641 if (isnan(time)) { | 3644 if (isnan(time)) { |
3642 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. | 3645 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. |
3643 time = i::OS::nan_value(); | 3646 time = i::OS::nan_value(); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3804 | 3807 |
3805 void V8::EnableSlidingStateWindow() { | 3808 void V8::EnableSlidingStateWindow() { |
3806 if (IsDeadCheck("v8::V8::EnableSlidingStateWindow()")) return; | 3809 if (IsDeadCheck("v8::V8::EnableSlidingStateWindow()")) return; |
3807 i::Logger::EnableSlidingStateWindow(); | 3810 i::Logger::EnableSlidingStateWindow(); |
3808 } | 3811 } |
3809 | 3812 |
3810 | 3813 |
3811 void V8::SetFailedAccessCheckCallbackFunction( | 3814 void V8::SetFailedAccessCheckCallbackFunction( |
3812 FailedAccessCheckCallback callback) { | 3815 FailedAccessCheckCallback callback) { |
3813 if (IsDeadCheck("v8::V8::SetFailedAccessCheckCallbackFunction()")) return; | 3816 if (IsDeadCheck("v8::V8::SetFailedAccessCheckCallbackFunction()")) return; |
3814 i::Top::SetFailedAccessCheckCallback(callback); | 3817 i::Isolate::Current()->SetFailedAccessCheckCallback(callback); |
3815 } | 3818 } |
3816 | 3819 |
3817 | 3820 |
3818 void V8::AddObjectGroup(Persistent<Value>* objects, size_t length) { | 3821 void V8::AddObjectGroup(Persistent<Value>* objects, size_t length) { |
3819 if (IsDeadCheck("v8::V8::AddObjectGroup()")) return; | 3822 if (IsDeadCheck("v8::V8::AddObjectGroup()")) return; |
3820 STATIC_ASSERT(sizeof(Persistent<Value>) == sizeof(i::Object**)); | 3823 STATIC_ASSERT(sizeof(Persistent<Value>) == sizeof(i::Object**)); |
3821 i::GlobalHandles::AddGroup(reinterpret_cast<i::Object***>(objects), length); | 3824 i::GlobalHandles::AddGroup(reinterpret_cast<i::Object***>(objects), length); |
3822 } | 3825 } |
3823 | 3826 |
3824 | 3827 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3930 ASSERT(max_size >= kMinimumSizeForLogLinesBuffer); | 3933 ASSERT(max_size >= kMinimumSizeForLogLinesBuffer); |
3931 return i::Logger::GetLogLines(from_pos, dest_buf, max_size); | 3934 return i::Logger::GetLogLines(from_pos, dest_buf, max_size); |
3932 #endif | 3935 #endif |
3933 return 0; | 3936 return 0; |
3934 } | 3937 } |
3935 | 3938 |
3936 | 3939 |
3937 int V8::GetCurrentThreadId() { | 3940 int V8::GetCurrentThreadId() { |
3938 API_ENTRY_CHECK("V8::GetCurrentThreadId()"); | 3941 API_ENTRY_CHECK("V8::GetCurrentThreadId()"); |
3939 EnsureInitialized("V8::GetCurrentThreadId()"); | 3942 EnsureInitialized("V8::GetCurrentThreadId()"); |
3940 return i::Top::thread_id(); | 3943 return i::Isolate::Current()->thread_id(); |
3941 } | 3944 } |
3942 | 3945 |
3943 | 3946 |
3944 void V8::TerminateExecution(int thread_id) { | 3947 void V8::TerminateExecution(int thread_id) { |
3945 if (!i::V8::IsRunning()) return; | 3948 if (!i::V8::IsRunning()) return; |
3946 API_ENTRY_CHECK("V8::GetCurrentThreadId()"); | 3949 API_ENTRY_CHECK("V8::GetCurrentThreadId()"); |
3947 i::Isolate* isolate = i::Isolate::Current(); | 3950 i::Isolate* isolate = i::Isolate::Current(); |
3948 // If the thread_id identifies the current thread just terminate | 3951 // If the thread_id identifies the current thread just terminate |
3949 // execution right away. Otherwise, ask the thread manager to | 3952 // execution right away. Otherwise, ask the thread manager to |
3950 // terminate the thread with the given id if any. | 3953 // terminate the thread with the given id if any. |
3951 if (thread_id == i::Top::thread_id()) { | 3954 if (thread_id == isolate->thread_id()) { |
3952 isolate->stack_guard()->TerminateExecution(); | 3955 isolate->stack_guard()->TerminateExecution(); |
3953 } else { | 3956 } else { |
3954 i::ThreadManager::TerminateExecution(thread_id); | 3957 i::ThreadManager::TerminateExecution(thread_id); |
3955 } | 3958 } |
3956 } | 3959 } |
3957 | 3960 |
3958 | 3961 |
3959 void V8::TerminateExecution() { | 3962 void V8::TerminateExecution() { |
3960 if (!i::V8::IsRunning()) return; | 3963 if (!i::V8::IsRunning()) return; |
3961 i::Isolate::Current()->stack_guard()->TerminateExecution(); | 3964 i::Isolate::Current()->stack_guard()->TerminateExecution(); |
3962 } | 3965 } |
3963 | 3966 |
3964 | 3967 |
3965 bool V8::IsExecutionTerminating() { | 3968 bool V8::IsExecutionTerminating() { |
3966 if (!i::V8::IsRunning()) return false; | 3969 if (!i::V8::IsRunning()) return false; |
3967 if (i::Top::has_scheduled_exception()) { | 3970 if (i::Isolate::Current()->has_scheduled_exception()) { |
3968 return i::Top::scheduled_exception() == HEAP->termination_exception(); | 3971 return i::Isolate::Current()->scheduled_exception() == |
| 3972 HEAP->termination_exception(); |
3969 } | 3973 } |
3970 return false; | 3974 return false; |
3971 } | 3975 } |
3972 | 3976 |
3973 | 3977 |
3974 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) { | 3978 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) { |
3975 EnsureInitialized("v8::String::Utf8Value::Utf8Value()"); | 3979 EnsureInitialized("v8::String::Utf8Value::Utf8Value()"); |
3976 if (obj.IsEmpty()) { | 3980 if (obj.IsEmpty()) { |
3977 str_ = NULL; | 3981 str_ = NULL; |
3978 length_ = 0; | 3982 length_ = 0; |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4707 | 4711 |
4708 | 4712 |
4709 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 4713 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
4710 HandleScopeImplementer* thread_local = | 4714 HandleScopeImplementer* thread_local = |
4711 reinterpret_cast<HandleScopeImplementer*>(storage); | 4715 reinterpret_cast<HandleScopeImplementer*>(storage); |
4712 thread_local->IterateThis(v); | 4716 thread_local->IterateThis(v); |
4713 return storage + ArchiveSpacePerThread(); | 4717 return storage + ArchiveSpacePerThread(); |
4714 } | 4718 } |
4715 | 4719 |
4716 } } // namespace v8::internal | 4720 } } // namespace v8::internal |
OLD | NEW |