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

Side by Side Diff: src/api.cc

Issue 6705024: Cleanup of Isolate::Current() usage in api.cc. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 ENTER_V8; 1381 ENTER_V8;
1382 Local<Script> generic = New(source, origin, pre_data, script_data); 1382 Local<Script> generic = New(source, origin, pre_data, script_data);
1383 if (generic.IsEmpty()) 1383 if (generic.IsEmpty())
1384 return generic; 1384 return generic;
1385 i::Handle<i::Object> obj = Utils::OpenHandle(*generic); 1385 i::Handle<i::Object> obj = Utils::OpenHandle(*generic);
1386 i::Handle<i::SharedFunctionInfo> function = 1386 i::Handle<i::SharedFunctionInfo> function =
1387 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj)); 1387 i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj));
1388 i::Handle<i::JSFunction> result = 1388 i::Handle<i::JSFunction> result =
1389 isolate->factory()->NewFunctionFromSharedFunctionInfo( 1389 isolate->factory()->NewFunctionFromSharedFunctionInfo(
1390 function, 1390 function,
1391 i::Isolate::Current()->global_context()); 1391 isolate->global_context());
1392 return Local<Script>(ToApi<Script>(result)); 1392 return Local<Script>(ToApi<Script>(result));
1393 } 1393 }
1394 1394
1395 1395
1396 Local<Script> Script::Compile(v8::Handle<String> source, 1396 Local<Script> Script::Compile(v8::Handle<String> source,
1397 v8::Handle<Value> file_name, 1397 v8::Handle<Value> file_name,
1398 v8::Handle<String> script_data) { 1398 v8::Handle<String> script_data) {
1399 ScriptOrigin origin(file_name); 1399 ScriptOrigin origin(file_name);
1400 return Compile(source, &origin, 0, script_data); 1400 return Compile(source, &origin, 0, script_data);
1401 } 1401 }
1402 1402
1403 1403
1404 Local<Value> Script::Run() { 1404 Local<Value> Script::Run() {
1405 i::Isolate* isolate = i::Isolate::Current(); 1405 i::Isolate* isolate = i::Isolate::Current();
1406 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); 1406 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>());
1407 LOG_API(isolate, "Script::Run"); 1407 LOG_API(isolate, "Script::Run");
1408 ENTER_V8; 1408 ENTER_V8;
1409 i::Object* raw_result = NULL; 1409 i::Object* raw_result = NULL;
1410 { 1410 {
1411 HandleScope scope; 1411 HandleScope scope;
1412 i::Handle<i::Object> obj = Utils::OpenHandle(this); 1412 i::Handle<i::Object> obj = Utils::OpenHandle(this);
1413 i::Handle<i::JSFunction> fun; 1413 i::Handle<i::JSFunction> fun;
1414 if (obj->IsSharedFunctionInfo()) { 1414 if (obj->IsSharedFunctionInfo()) {
1415 i::Handle<i::SharedFunctionInfo> 1415 i::Handle<i::SharedFunctionInfo>
1416 function_info(i::SharedFunctionInfo::cast(*obj)); 1416 function_info(i::SharedFunctionInfo::cast(*obj));
1417 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo( 1417 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo(
1418 function_info, i::Isolate::Current()->global_context()); 1418 function_info, isolate->global_context());
1419 } else { 1419 } else {
1420 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj)); 1420 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj));
1421 } 1421 }
1422 EXCEPTION_PREAMBLE(); 1422 EXCEPTION_PREAMBLE();
1423 i::Handle<i::Object> receiver( 1423 i::Handle<i::Object> receiver(
1424 i::Isolate::Current()->context()->global_proxy()); 1424 isolate->context()->global_proxy());
1425 i::Handle<i::Object> result = 1425 i::Handle<i::Object> result =
1426 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); 1426 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception);
1427 EXCEPTION_BAILOUT_CHECK(Local<Value>()); 1427 EXCEPTION_BAILOUT_CHECK(Local<Value>());
1428 raw_result = *result; 1428 raw_result = *result;
1429 } 1429 }
1430 i::Handle<i::Object> result(raw_result); 1430 i::Handle<i::Object> result(raw_result);
1431 return Utils::ToLocal(result); 1431 return Utils::ToLocal(result);
1432 } 1432 }
1433 1433
1434 1434
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 message_(i::Smi::FromInt(0)), 1486 message_(i::Smi::FromInt(0)),
1487 is_verbose_(false), 1487 is_verbose_(false),
1488 can_continue_(true), 1488 can_continue_(true),
1489 capture_message_(true), 1489 capture_message_(true),
1490 rethrow_(false) { 1490 rethrow_(false) {
1491 i::Isolate::Current()->RegisterTryCatchHandler(this); 1491 i::Isolate::Current()->RegisterTryCatchHandler(this);
1492 } 1492 }
1493 1493
1494 1494
1495 v8::TryCatch::~TryCatch() { 1495 v8::TryCatch::~TryCatch() {
1496 i::Isolate* isolate = i::Isolate::Current();
1496 if (rethrow_) { 1497 if (rethrow_) {
1497 v8::HandleScope scope; 1498 v8::HandleScope scope;
1498 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception()); 1499 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception());
1499 i::Isolate::Current()->UnregisterTryCatchHandler(this); 1500 isolate->UnregisterTryCatchHandler(this);
1500 v8::ThrowException(exc); 1501 v8::ThrowException(exc);
1501 } else { 1502 } else {
1502 i::Isolate::Current()->UnregisterTryCatchHandler(this); 1503 isolate->UnregisterTryCatchHandler(this);
1503 } 1504 }
1504 } 1505 }
1505 1506
1506 1507
1507 bool v8::TryCatch::HasCaught() const { 1508 bool v8::TryCatch::HasCaught() const {
1508 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); 1509 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole();
1509 } 1510 }
1510 1511
1511 1512
1512 bool v8::TryCatch::CanContinue() const { 1513 bool v8::TryCatch::CanContinue() const {
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 2031
2031 bool Value::IsRegExp() const { 2032 bool Value::IsRegExp() const {
2032 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false; 2033 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsRegExp()")) return false;
2033 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2034 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2034 return obj->IsJSRegExp(); 2035 return obj->IsJSRegExp();
2035 } 2036 }
2036 2037
2037 2038
2038 Local<String> Value::ToString() const { 2039 Local<String> Value::ToString() const {
2039 i::Isolate* isolate = i::Isolate::Current(); 2040 i::Isolate* isolate = i::Isolate::Current();
2040 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::ToString()")) { 2041 if (IsDeadCheck(isolate, "v8::Value::ToString()")) {
2041 return Local<String>(); 2042 return Local<String>();
2042 } 2043 }
2043 LOG_API(isolate, "ToString"); 2044 LOG_API(isolate, "ToString");
2044 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2045 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2045 i::Handle<i::Object> str; 2046 i::Handle<i::Object> str;
2046 if (obj->IsString()) { 2047 if (obj->IsString()) {
2047 str = obj; 2048 str = obj;
2048 } else { 2049 } else {
2049 ENTER_V8; 2050 ENTER_V8;
2050 EXCEPTION_PREAMBLE(); 2051 EXCEPTION_PREAMBLE();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 EXCEPTION_PREAMBLE(); 2089 EXCEPTION_PREAMBLE();
2089 val = i::Execution::ToObject(obj, &has_pending_exception); 2090 val = i::Execution::ToObject(obj, &has_pending_exception);
2090 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>()); 2091 EXCEPTION_BAILOUT_CHECK(Local<v8::Object>());
2091 } 2092 }
2092 return Local<v8::Object>(ToApi<Object>(val)); 2093 return Local<v8::Object>(ToApi<Object>(val));
2093 } 2094 }
2094 2095
2095 2096
2096 Local<Boolean> Value::ToBoolean() const { 2097 Local<Boolean> Value::ToBoolean() const {
2097 i::Isolate* isolate = i::Isolate::Current(); 2098 i::Isolate* isolate = i::Isolate::Current();
2098 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::ToBoolean()")) { 2099 if (IsDeadCheck(isolate, "v8::Value::ToBoolean()")) {
2099 return Local<Boolean>(); 2100 return Local<Boolean>();
2100 } 2101 }
2101 LOG_API(isolate, "ToBoolean"); 2102 LOG_API(isolate, "ToBoolean");
2102 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2103 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2103 if (obj->IsBoolean()) { 2104 if (obj->IsBoolean()) {
2104 return Local<Boolean>(ToApi<Boolean>(obj)); 2105 return Local<Boolean>(ToApi<Boolean>(obj));
2105 } else { 2106 } else {
2106 ENTER_V8; 2107 ENTER_V8;
2107 i::Handle<i::Object> val = i::Execution::ToBoolean(obj); 2108 i::Handle<i::Object> val = i::Execution::ToBoolean(obj);
2108 return Local<Boolean>(ToApi<Boolean>(val)); 2109 return Local<Boolean>(ToApi<Boolean>(val));
(...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after
3650 3651
3651 // Restore the access check info on the global template. 3652 // Restore the access check info on the global template.
3652 if (!global_template.IsEmpty()) { 3653 if (!global_template.IsEmpty()) {
3653 ASSERT(!global_constructor.is_null()); 3654 ASSERT(!global_constructor.is_null());
3654 ASSERT(!proxy_constructor.is_null()); 3655 ASSERT(!proxy_constructor.is_null());
3655 global_constructor->set_access_check_info( 3656 global_constructor->set_access_check_info(
3656 proxy_constructor->access_check_info()); 3657 proxy_constructor->access_check_info());
3657 global_constructor->set_needs_access_check( 3658 global_constructor->set_needs_access_check(
3658 proxy_constructor->needs_access_check()); 3659 proxy_constructor->needs_access_check());
3659 } 3660 }
3660 i::Isolate::Current()->runtime_profiler()->Reset(); 3661 isolate->runtime_profiler()->Reset();
3661 } 3662 }
3662 // Leave V8. 3663 // Leave V8.
3663 3664
3664 if (env.is_null()) 3665 if (env.is_null())
3665 return Persistent<Context>(); 3666 return Persistent<Context>();
3666 return Persistent<Context>(Utils::ToLocal(env)); 3667 return Persistent<Context>(Utils::ToLocal(env));
3667 } 3668 }
3668 3669
3669 3670
3670 void v8::Context::SetSecurityToken(Handle<Value> token) { 3671 void v8::Context::SetSecurityToken(Handle<Value> token) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3705 return env->has_out_of_memory(); 3706 return env->has_out_of_memory();
3706 } 3707 }
3707 3708
3708 3709
3709 bool Context::InContext() { 3710 bool Context::InContext() {
3710 return i::Isolate::Current()->context() != NULL; 3711 return i::Isolate::Current()->context() != NULL;
3711 } 3712 }
3712 3713
3713 3714
3714 v8::Local<v8::Context> Context::GetEntered() { 3715 v8::Local<v8::Context> Context::GetEntered() {
3715 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::GetEntered()")) { 3716 i::Isolate* isolate = i::Isolate::Current();
3717 if (IsDeadCheck(isolate, "v8::Context::GetEntered()")) {
3716 return Local<Context>(); 3718 return Local<Context>();
3717 } 3719 }
3718 i::Handle<i::Object> last = 3720 i::Handle<i::Object> last =
3719 i::Isolate::Current()->handle_scope_implementer()->LastEnteredContext(); 3721 isolate->handle_scope_implementer()->LastEnteredContext();
3720 if (last.is_null()) return Local<Context>(); 3722 if (last.is_null()) return Local<Context>();
3721 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last); 3723 i::Handle<i::Context> context = i::Handle<i::Context>::cast(last);
3722 return Utils::ToLocal(context); 3724 return Utils::ToLocal(context);
3723 } 3725 }
3724 3726
3725 3727
3726 v8::Local<v8::Context> Context::GetCurrent() { 3728 v8::Local<v8::Context> Context::GetCurrent() {
3727 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::GetCurrent()")) { 3729 i::Isolate* isolate = i::Isolate::Current();
3730 if (IsDeadCheck(isolate, "v8::Context::GetCurrent()")) {
3728 return Local<Context>(); 3731 return Local<Context>();
3729 } 3732 }
3730 i::Handle<i::Object> current = i::Isolate::Current()->global_context(); 3733 i::Handle<i::Object> current = isolate->global_context();
3731 if (current.is_null()) return Local<Context>(); 3734 if (current.is_null()) return Local<Context>();
3732 i::Handle<i::Context> context = i::Handle<i::Context>::cast(current); 3735 i::Handle<i::Context> context = i::Handle<i::Context>::cast(current);
3733 return Utils::ToLocal(context); 3736 return Utils::ToLocal(context);
3734 } 3737 }
3735 3738
3736 3739
3737 v8::Local<v8::Context> Context::GetCalling() { 3740 v8::Local<v8::Context> Context::GetCalling() {
3738 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::GetCalling()")) { 3741 i::Isolate* isolate = i::Isolate::Current();
3742 if (IsDeadCheck(isolate, "v8::Context::GetCalling()")) {
3739 return Local<Context>(); 3743 return Local<Context>();
3740 } 3744 }
3741 i::Handle<i::Object> calling = 3745 i::Handle<i::Object> calling =
3742 i::Isolate::Current()->GetCallingGlobalContext(); 3746 isolate->GetCallingGlobalContext();
3743 if (calling.is_null()) return Local<Context>(); 3747 if (calling.is_null()) return Local<Context>();
3744 i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling); 3748 i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling);
3745 return Utils::ToLocal(context); 3749 return Utils::ToLocal(context);
3746 } 3750 }
3747 3751
3748 3752
3749 v8::Local<v8::Object> Context::Global() { 3753 v8::Local<v8::Object> Context::Global() {
3750 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::Global()")) { 3754 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::Global()")) {
3751 return Local<v8::Object>(); 3755 return Local<v8::Object>();
3752 } 3756 }
3753 i::Object** ctx = reinterpret_cast<i::Object**>(this); 3757 i::Object** ctx = reinterpret_cast<i::Object**>(this);
3754 i::Handle<i::Context> context = 3758 i::Handle<i::Context> context =
3755 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); 3759 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
3756 i::Handle<i::Object> global(context->global_proxy()); 3760 i::Handle<i::Object> global(context->global_proxy());
3757 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global)); 3761 return Utils::ToLocal(i::Handle<i::JSObject>::cast(global));
3758 } 3762 }
3759 3763
3760 3764
3761 void Context::DetachGlobal() { 3765 void Context::DetachGlobal() {
3762 if (IsDeadCheck(i::Isolate::Current(), "v8::Context::DetachGlobal()")) return; 3766 i::Isolate* isolate = i::Isolate::Current();
3767 if (IsDeadCheck(isolate, "v8::Context::DetachGlobal()")) return;
3763 ENTER_V8; 3768 ENTER_V8;
3764 i::Object** ctx = reinterpret_cast<i::Object**>(this); 3769 i::Object** ctx = reinterpret_cast<i::Object**>(this);
3765 i::Handle<i::Context> context = 3770 i::Handle<i::Context> context =
3766 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); 3771 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
3767 i::Isolate::Current()->bootstrapper()->DetachGlobal(context); 3772 isolate->bootstrapper()->DetachGlobal(context);
3768 } 3773 }
3769 3774
3770 3775
3771 void Context::ReattachGlobal(Handle<Object> global_object) { 3776 void Context::ReattachGlobal(Handle<Object> global_object) {
3772 i::Isolate* isolate = i::Isolate::Current(); 3777 i::Isolate* isolate = i::Isolate::Current();
3773 if (IsDeadCheck(isolate, "v8::Context::ReattachGlobal()")) return; 3778 if (IsDeadCheck(isolate, "v8::Context::ReattachGlobal()")) return;
3774 ENTER_V8; 3779 ENTER_V8;
3775 i::Object** ctx = reinterpret_cast<i::Object**>(this); 3780 i::Object** ctx = reinterpret_cast<i::Object**>(this);
3776 i::Handle<i::Context> context = 3781 i::Handle<i::Context> context =
3777 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx)); 3782 i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
4068 return !shape.IsExternal(); 4073 return !shape.IsExternal();
4069 } 4074 }
4070 4075
4071 4076
4072 Local<v8::Object> v8::Object::New() { 4077 Local<v8::Object> v8::Object::New() {
4073 i::Isolate* isolate = i::Isolate::Current(); 4078 i::Isolate* isolate = i::Isolate::Current();
4074 EnsureInitializedForIsolate(isolate, "v8::Object::New()"); 4079 EnsureInitializedForIsolate(isolate, "v8::Object::New()");
4075 LOG_API(isolate, "Object::New"); 4080 LOG_API(isolate, "Object::New");
4076 ENTER_V8; 4081 ENTER_V8;
4077 i::Handle<i::JSObject> obj = 4082 i::Handle<i::JSObject> obj =
4078 isolate->factory()->NewJSObject(i::Isolate::Current()->object_function()); 4083 isolate->factory()->NewJSObject(isolate->object_function());
4079 return Utils::ToLocal(obj); 4084 return Utils::ToLocal(obj);
4080 } 4085 }
4081 4086
4082 4087
4083 Local<v8::Value> v8::Date::New(double time) { 4088 Local<v8::Value> v8::Date::New(double time) {
4084 i::Isolate* isolate = i::Isolate::Current(); 4089 i::Isolate* isolate = i::Isolate::Current();
4085 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); 4090 EnsureInitializedForIsolate(isolate, "v8::Date::New()");
4086 LOG_API(isolate, "Date::New"); 4091 LOG_API(isolate, "Date::New");
4087 if (isnan(time)) { 4092 if (isnan(time)) {
4088 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 4093 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
4543 4548
4544 4549
4545 int V8::GetCurrentThreadId() { 4550 int V8::GetCurrentThreadId() {
4546 API_ENTRY_CHECK("V8::GetCurrentThreadId()"); 4551 API_ENTRY_CHECK("V8::GetCurrentThreadId()");
4547 EnsureInitialized("V8::GetCurrentThreadId()"); 4552 EnsureInitialized("V8::GetCurrentThreadId()");
4548 return i::Isolate::Current()->thread_id(); 4553 return i::Isolate::Current()->thread_id();
4549 } 4554 }
4550 4555
4551 4556
4552 void V8::TerminateExecution(int thread_id) { 4557 void V8::TerminateExecution(int thread_id) {
4553 if (!i::Isolate::Current()->IsInitialized()) return; 4558 i::Isolate* isolate = i::Isolate::Current();
4559 if (!isolate->IsInitialized()) return;
4554 API_ENTRY_CHECK("V8::GetCurrentThreadId()"); 4560 API_ENTRY_CHECK("V8::GetCurrentThreadId()");
4555 i::Isolate* isolate = i::Isolate::Current();
4556 // If the thread_id identifies the current thread just terminate 4561 // If the thread_id identifies the current thread just terminate
4557 // execution right away. Otherwise, ask the thread manager to 4562 // execution right away. Otherwise, ask the thread manager to
4558 // terminate the thread with the given id if any. 4563 // terminate the thread with the given id if any.
4559 if (thread_id == isolate->thread_id()) { 4564 if (thread_id == isolate->thread_id()) {
4560 isolate->stack_guard()->TerminateExecution(); 4565 isolate->stack_guard()->TerminateExecution();
4561 } else { 4566 } else {
4562 isolate->thread_manager()->TerminateExecution(thread_id); 4567 isolate->thread_manager()->TerminateExecution(thread_id);
4563 } 4568 }
4564 } 4569 }
4565 4570
4566 4571
4567 void V8::TerminateExecution(Isolate* isolate) { 4572 void V8::TerminateExecution(Isolate* isolate) {
4568 // If no isolate is supplied, use the default isolate. 4573 // If no isolate is supplied, use the default isolate.
4569 if (isolate != NULL) { 4574 if (isolate != NULL) {
4570 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution(); 4575 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution();
4571 } else { 4576 } else {
4572 i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution(); 4577 i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution();
4573 } 4578 }
4574 } 4579 }
4575 4580
4576 4581
4577 bool V8::IsExecutionTerminating() { 4582 bool V8::IsExecutionTerminating() {
4578 if (!i::Isolate::Current()->IsInitialized()) return false; 4583 i::Isolate* isolate = i::Isolate::Current();
4579 if (i::Isolate::Current()->has_scheduled_exception()) { 4584 if (!isolate->IsInitialized()) return false;
4580 return i::Isolate::Current()->scheduled_exception() == 4585 if (isolate->has_scheduled_exception()) {
4586 return isolate->scheduled_exception() ==
4581 HEAP->termination_exception(); 4587 HEAP->termination_exception();
4582 } 4588 }
4583 return false; 4589 return false;
4584 } 4590 }
4585 4591
4586 4592
4587 Isolate* Isolate::GetCurrent() { 4593 Isolate* Isolate::GetCurrent() {
4588 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); 4594 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
4589 return reinterpret_cast<Isolate*>(isolate); 4595 return reinterpret_cast<Isolate*>(isolate);
4590 } 4596 }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
4887 EnsureInitialized("v8::Debug::SetMessageHandler"); 4893 EnsureInitialized("v8::Debug::SetMessageHandler");
4888 ENTER_V8; 4894 ENTER_V8;
4889 i::Isolate* isolate = i::Isolate::Current(); 4895 i::Isolate* isolate = i::Isolate::Current();
4890 // Message handler thread not supported any more. Parameter temporally left in 4896 // Message handler thread not supported any more. Parameter temporally left in
4891 // the API for client compatability reasons. 4897 // the API for client compatability reasons.
4892 CHECK(!message_handler_thread); 4898 CHECK(!message_handler_thread);
4893 4899
4894 // TODO(sgjesse) support the old message handler API through a simple wrapper. 4900 // TODO(sgjesse) support the old message handler API through a simple wrapper.
4895 isolate->set_message_handler(handler); 4901 isolate->set_message_handler(handler);
4896 if (handler != NULL) { 4902 if (handler != NULL) {
4897 i::Isolate::Current()->debugger()->SetMessageHandler(MessageHandlerWrapper); 4903 isolate->debugger()->SetMessageHandler(MessageHandlerWrapper);
4898 } else { 4904 } else {
4899 i::Isolate::Current()->debugger()->SetMessageHandler(NULL); 4905 isolate->debugger()->SetMessageHandler(NULL);
4900 } 4906 }
4901 } 4907 }
4902 4908
4903 4909
4904 void Debug::SetMessageHandler2(v8::Debug::MessageHandler2 handler) { 4910 void Debug::SetMessageHandler2(v8::Debug::MessageHandler2 handler) {
4905 EnsureInitialized("v8::Debug::SetMessageHandler"); 4911 EnsureInitialized("v8::Debug::SetMessageHandler");
4906 ENTER_V8; 4912 ENTER_V8;
4907 i::Isolate::Current()->debugger()->SetMessageHandler(handler); 4913 i::Isolate::Current()->debugger()->SetMessageHandler(handler);
4908 } 4914 }
4909 4915
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4942 4948
4943 Local<Value> Debug::Call(v8::Handle<v8::Function> fun, 4949 Local<Value> Debug::Call(v8::Handle<v8::Function> fun,
4944 v8::Handle<v8::Value> data) { 4950 v8::Handle<v8::Value> data) {
4945 i::Isolate* isolate = i::Isolate::Current(); 4951 i::Isolate* isolate = i::Isolate::Current();
4946 if (!isolate->IsInitialized()) return Local<Value>(); 4952 if (!isolate->IsInitialized()) return Local<Value>();
4947 ON_BAILOUT(isolate, "v8::Debug::Call()", return Local<Value>()); 4953 ON_BAILOUT(isolate, "v8::Debug::Call()", return Local<Value>());
4948 ENTER_V8; 4954 ENTER_V8;
4949 i::Handle<i::Object> result; 4955 i::Handle<i::Object> result;
4950 EXCEPTION_PREAMBLE(); 4956 EXCEPTION_PREAMBLE();
4951 if (data.IsEmpty()) { 4957 if (data.IsEmpty()) {
4952 result = i::Isolate::Current()->debugger()->Call( 4958 result = isolate->debugger()->Call(
4953 Utils::OpenHandle(*fun), 4959 Utils::OpenHandle(*fun),
4954 isolate->factory()->undefined_value(), 4960 isolate->factory()->undefined_value(),
4955 &has_pending_exception); 4961 &has_pending_exception);
4956 } else { 4962 } else {
4957 result = i::Isolate::Current()->debugger()->Call(Utils::OpenHandle(*fun), 4963 result = isolate->debugger()->Call(Utils::OpenHandle(*fun),
4958 Utils::OpenHandle(*data), 4964 Utils::OpenHandle(*data),
4959 &has_pending_exception); 4965 &has_pending_exception);
4960 } 4966 }
4961 EXCEPTION_BAILOUT_CHECK(Local<Value>()); 4967 EXCEPTION_BAILOUT_CHECK(Local<Value>());
4962 return Utils::ToLocal(result); 4968 return Utils::ToLocal(result);
4963 } 4969 }
4964 4970
4965 4971
4966 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) { 4972 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) {
4967 i::Isolate* isolate = i::Isolate::Current(); 4973 i::Isolate* isolate = i::Isolate::Current();
4968 if (!isolate->IsInitialized()) return Local<Value>(); 4974 if (!isolate->IsInitialized()) return Local<Value>();
4969 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>()); 4975 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>());
4970 ENTER_V8; 4976 ENTER_V8;
4971 v8::HandleScope scope; 4977 v8::HandleScope scope;
4972 i::Debug* isolate_debug = i::Isolate::Current()->debug(); 4978 i::Debug* isolate_debug = isolate->debug();
4973 isolate_debug->Load(); 4979 isolate_debug->Load();
4974 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global()); 4980 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global());
4975 i::Handle<i::String> name = 4981 i::Handle<i::String> name =
4976 isolate->factory()->LookupAsciiSymbol("MakeMirror"); 4982 isolate->factory()->LookupAsciiSymbol("MakeMirror");
4977 i::Handle<i::Object> fun_obj = i::GetProperty(debug, name); 4983 i::Handle<i::Object> fun_obj = i::GetProperty(debug, name);
4978 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); 4984 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj);
4979 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); 4985 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun);
4980 const int kArgc = 1; 4986 const int kArgc = 1;
4981 v8::Handle<v8::Value> argv[kArgc] = { obj }; 4987 v8::Handle<v8::Value> argv[kArgc] = { obj };
4982 EXCEPTION_PREAMBLE(); 4988 EXCEPTION_PREAMBLE();
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
5660 5666
5661 5667
5662 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5668 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5663 HandleScopeImplementer* thread_local = 5669 HandleScopeImplementer* thread_local =
5664 reinterpret_cast<HandleScopeImplementer*>(storage); 5670 reinterpret_cast<HandleScopeImplementer*>(storage);
5665 thread_local->IterateThis(v); 5671 thread_local->IterateThis(v);
5666 return storage + ArchiveSpacePerThread(); 5672 return storage + ArchiveSpacePerThread();
5667 } 5673 }
5668 5674
5669 } } // namespace v8::internal 5675 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698