| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 UNREACHABLE(); \ | 71 UNREACHABLE(); \ |
| 72 } | 72 } |
| 73 | 73 |
| 74 | 74 |
| 75 #define EXCEPTION_PREAMBLE(isolate) \ | 75 #define EXCEPTION_PREAMBLE(isolate) \ |
| 76 (isolate)->handle_scope_implementer()->IncrementCallDepth(); \ | 76 (isolate)->handle_scope_implementer()->IncrementCallDepth(); \ |
| 77 ASSERT(!(isolate)->external_caught_exception()); \ | 77 ASSERT(!(isolate)->external_caught_exception()); \ |
| 78 bool has_pending_exception = false | 78 bool has_pending_exception = false |
| 79 | 79 |
| 80 | 80 |
| 81 #define EXCEPTION_BAILOUT_CHECK(isolate, value) \ | 81 #define EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, do_callback) \ |
| 82 do { \ | 82 do { \ |
| 83 i::HandleScopeImplementer* handle_scope_implementer = \ | 83 i::HandleScopeImplementer* handle_scope_implementer = \ |
| 84 (isolate)->handle_scope_implementer(); \ | 84 (isolate)->handle_scope_implementer(); \ |
| 85 handle_scope_implementer->DecrementCallDepth(); \ | 85 handle_scope_implementer->DecrementCallDepth(); \ |
| 86 if (has_pending_exception) { \ | 86 if (has_pending_exception) { \ |
| 87 if (handle_scope_implementer->CallDepthIsZero() && \ | 87 if (handle_scope_implementer->CallDepthIsZero() && \ |
| 88 (isolate)->is_out_of_memory()) { \ | 88 (isolate)->is_out_of_memory()) { \ |
| 89 if (!(isolate)->ignore_out_of_memory()) \ | 89 if (!(isolate)->ignore_out_of_memory()) \ |
| 90 i::V8::FatalProcessOutOfMemory(NULL); \ | 90 i::V8::FatalProcessOutOfMemory(NULL); \ |
| 91 } \ | 91 } \ |
| 92 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ | 92 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ |
| 93 (isolate)->OptionalRescheduleException(call_depth_is_zero); \ | 93 (isolate)->OptionalRescheduleException(call_depth_is_zero); \ |
| 94 do_callback \ |
| 94 return value; \ | 95 return value; \ |
| 95 } \ | 96 } \ |
| 97 do_callback \ |
| 96 } while (false) | 98 } while (false) |
| 97 | 99 |
| 98 | 100 |
| 101 #define EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, value) \ |
| 102 EXCEPTION_BAILOUT_CHECK_GENERIC( \ |
| 103 isolate, value, i::V8::FireCallCompletedCallback(isolate);) |
| 104 |
| 105 |
| 106 #define EXCEPTION_BAILOUT_CHECK(isolate, value) \ |
| 107 EXCEPTION_BAILOUT_CHECK_GENERIC(isolate, value, ;) |
| 108 |
| 109 |
| 99 #define API_ENTRY_CHECK(isolate, msg) \ | 110 #define API_ENTRY_CHECK(isolate, msg) \ |
| 100 do { \ | 111 do { \ |
| 101 if (v8::Locker::IsActive()) { \ | 112 if (v8::Locker::IsActive()) { \ |
| 102 ApiCheck(isolate->thread_manager()->IsLockedByCurrentThread(), \ | 113 ApiCheck(isolate->thread_manager()->IsLockedByCurrentThread(), \ |
| 103 msg, \ | 114 msg, \ |
| 104 "Entering the V8 API without proper locking in place"); \ | 115 "Entering the V8 API without proper locking in place"); \ |
| 105 } \ | 116 } \ |
| 106 } while (false) | 117 } while (false) |
| 107 | 118 |
| 108 | 119 |
| (...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo( | 1572 fun = isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 1562 function_info, isolate->global_context()); | 1573 function_info, isolate->global_context()); |
| 1563 } else { | 1574 } else { |
| 1564 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate); | 1575 fun = i::Handle<i::JSFunction>(i::JSFunction::cast(*obj), isolate); |
| 1565 } | 1576 } |
| 1566 EXCEPTION_PREAMBLE(isolate); | 1577 EXCEPTION_PREAMBLE(isolate); |
| 1567 i::Handle<i::Object> receiver( | 1578 i::Handle<i::Object> receiver( |
| 1568 isolate->context()->global_proxy(), isolate); | 1579 isolate->context()->global_proxy(), isolate); |
| 1569 i::Handle<i::Object> result = | 1580 i::Handle<i::Object> result = |
| 1570 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); | 1581 i::Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); |
| 1571 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 1582 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>()); |
| 1572 raw_result = *result; | 1583 raw_result = *result; |
| 1573 } | 1584 } |
| 1574 i::Handle<i::Object> result(raw_result, isolate); | 1585 i::Handle<i::Object> result(raw_result, isolate); |
| 1575 return Utils::ToLocal(result); | 1586 return Utils::ToLocal(result); |
| 1576 } | 1587 } |
| 1577 | 1588 |
| 1578 | 1589 |
| 1579 static i::Handle<i::SharedFunctionInfo> OpenScript(Script* script) { | 1590 static i::Handle<i::SharedFunctionInfo> OpenScript(Script* script) { |
| 1580 i::Handle<i::Object> obj = Utils::OpenHandle(script); | 1591 i::Handle<i::Object> obj = Utils::OpenHandle(script); |
| 1581 i::Handle<i::SharedFunctionInfo> result; | 1592 i::Handle<i::SharedFunctionInfo> result; |
| (...skipping 1905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3487 EXCEPTION_PREAMBLE(isolate); | 3498 EXCEPTION_PREAMBLE(isolate); |
| 3488 i::Handle<i::Object> delegate = | 3499 i::Handle<i::Object> delegate = |
| 3489 i::Execution::TryGetFunctionDelegate(obj, &has_pending_exception); | 3500 i::Execution::TryGetFunctionDelegate(obj, &has_pending_exception); |
| 3490 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 3501 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
| 3491 fun = i::Handle<i::JSFunction>::cast(delegate); | 3502 fun = i::Handle<i::JSFunction>::cast(delegate); |
| 3492 recv_obj = obj; | 3503 recv_obj = obj; |
| 3493 } | 3504 } |
| 3494 EXCEPTION_PREAMBLE(isolate); | 3505 EXCEPTION_PREAMBLE(isolate); |
| 3495 i::Handle<i::Object> returned = | 3506 i::Handle<i::Object> returned = |
| 3496 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); | 3507 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); |
| 3497 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 3508 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>()); |
| 3498 return Utils::ToLocal(scope.CloseAndEscape(returned)); | 3509 return Utils::ToLocal(scope.CloseAndEscape(returned)); |
| 3499 } | 3510 } |
| 3500 | 3511 |
| 3501 | 3512 |
| 3502 Local<v8::Value> Object::CallAsConstructor(int argc, | 3513 Local<v8::Value> Object::CallAsConstructor(int argc, |
| 3503 v8::Handle<v8::Value> argv[]) { | 3514 v8::Handle<v8::Value> argv[]) { |
| 3504 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3515 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3505 ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()", | 3516 ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()", |
| 3506 return Local<v8::Object>()); | 3517 return Local<v8::Object>()); |
| 3507 LOG_API(isolate, "Object::CallAsConstructor"); | 3518 LOG_API(isolate, "Object::CallAsConstructor"); |
| 3508 ENTER_V8(isolate); | 3519 ENTER_V8(isolate); |
| 3509 i::HandleScope scope(isolate); | 3520 i::HandleScope scope(isolate); |
| 3510 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 3521 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
| 3511 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 3522 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
| 3512 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 3523 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 3513 if (obj->IsJSFunction()) { | 3524 if (obj->IsJSFunction()) { |
| 3514 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj); | 3525 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj); |
| 3515 EXCEPTION_PREAMBLE(isolate); | 3526 EXCEPTION_PREAMBLE(isolate); |
| 3516 i::Handle<i::Object> returned = | 3527 i::Handle<i::Object> returned = |
| 3517 i::Execution::New(fun, argc, args, &has_pending_exception); | 3528 i::Execution::New(fun, argc, args, &has_pending_exception); |
| 3518 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); | 3529 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>()); |
| 3519 return Utils::ToLocal(scope.CloseAndEscape( | 3530 return Utils::ToLocal(scope.CloseAndEscape( |
| 3520 i::Handle<i::JSObject>::cast(returned))); | 3531 i::Handle<i::JSObject>::cast(returned))); |
| 3521 } | 3532 } |
| 3522 EXCEPTION_PREAMBLE(isolate); | 3533 EXCEPTION_PREAMBLE(isolate); |
| 3523 i::Handle<i::Object> delegate = | 3534 i::Handle<i::Object> delegate = |
| 3524 i::Execution::TryGetConstructorDelegate(obj, &has_pending_exception); | 3535 i::Execution::TryGetConstructorDelegate(obj, &has_pending_exception); |
| 3525 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); | 3536 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); |
| 3526 if (!delegate->IsUndefined()) { | 3537 if (!delegate->IsUndefined()) { |
| 3527 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(delegate); | 3538 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(delegate); |
| 3528 EXCEPTION_PREAMBLE(isolate); | 3539 EXCEPTION_PREAMBLE(isolate); |
| 3529 i::Handle<i::Object> returned = | 3540 i::Handle<i::Object> returned = |
| 3530 i::Execution::Call(fun, obj, argc, args, &has_pending_exception); | 3541 i::Execution::Call(fun, obj, argc, args, &has_pending_exception); |
| 3531 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); | 3542 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>()); |
| 3532 ASSERT(!delegate->IsUndefined()); | 3543 ASSERT(!delegate->IsUndefined()); |
| 3533 return Utils::ToLocal(scope.CloseAndEscape(returned)); | 3544 return Utils::ToLocal(scope.CloseAndEscape(returned)); |
| 3534 } | 3545 } |
| 3535 return Local<v8::Object>(); | 3546 return Local<v8::Object>(); |
| 3536 } | 3547 } |
| 3537 | 3548 |
| 3538 | 3549 |
| 3539 Local<v8::Object> Function::NewInstance() const { | 3550 Local<v8::Object> Function::NewInstance() const { |
| 3540 return NewInstance(0, NULL); | 3551 return NewInstance(0, NULL); |
| 3541 } | 3552 } |
| 3542 | 3553 |
| 3543 | 3554 |
| 3544 Local<v8::Object> Function::NewInstance(int argc, | 3555 Local<v8::Object> Function::NewInstance(int argc, |
| 3545 v8::Handle<v8::Value> argv[]) const { | 3556 v8::Handle<v8::Value> argv[]) const { |
| 3546 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3557 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3547 ON_BAILOUT(isolate, "v8::Function::NewInstance()", | 3558 ON_BAILOUT(isolate, "v8::Function::NewInstance()", |
| 3548 return Local<v8::Object>()); | 3559 return Local<v8::Object>()); |
| 3549 LOG_API(isolate, "Function::NewInstance"); | 3560 LOG_API(isolate, "Function::NewInstance"); |
| 3550 ENTER_V8(isolate); | 3561 ENTER_V8(isolate); |
| 3551 HandleScope scope; | 3562 HandleScope scope; |
| 3552 i::Handle<i::JSFunction> function = Utils::OpenHandle(this); | 3563 i::Handle<i::JSFunction> function = Utils::OpenHandle(this); |
| 3553 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 3564 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
| 3554 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 3565 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 3555 EXCEPTION_PREAMBLE(isolate); | 3566 EXCEPTION_PREAMBLE(isolate); |
| 3556 i::Handle<i::Object> returned = | 3567 i::Handle<i::Object> returned = |
| 3557 i::Execution::New(function, argc, args, &has_pending_exception); | 3568 i::Execution::New(function, argc, args, &has_pending_exception); |
| 3558 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); | 3569 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>()); |
| 3559 return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); | 3570 return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); |
| 3560 } | 3571 } |
| 3561 | 3572 |
| 3562 | 3573 |
| 3563 Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc, | 3574 Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc, |
| 3564 v8::Handle<v8::Value> argv[]) { | 3575 v8::Handle<v8::Value> argv[]) { |
| 3565 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3576 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3566 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>()); | 3577 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>()); |
| 3567 LOG_API(isolate, "Function::Call"); | 3578 LOG_API(isolate, "Function::Call"); |
| 3568 ENTER_V8(isolate); | 3579 ENTER_V8(isolate); |
| 3569 i::Object* raw_result = NULL; | 3580 i::Object* raw_result = NULL; |
| 3570 { | 3581 { |
| 3571 i::HandleScope scope(isolate); | 3582 i::HandleScope scope(isolate); |
| 3572 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); | 3583 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); |
| 3573 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); | 3584 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); |
| 3574 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 3585 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
| 3575 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 3586 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
| 3576 EXCEPTION_PREAMBLE(isolate); | 3587 EXCEPTION_PREAMBLE(isolate); |
| 3577 i::Handle<i::Object> returned = | 3588 i::Handle<i::Object> returned = |
| 3578 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); | 3589 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); |
| 3579 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); | 3590 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Object>()); |
| 3580 raw_result = *returned; | 3591 raw_result = *returned; |
| 3581 } | 3592 } |
| 3582 i::Handle<i::Object> result(raw_result); | 3593 i::Handle<i::Object> result(raw_result); |
| 3583 return Utils::ToLocal(result); | 3594 return Utils::ToLocal(result); |
| 3584 } | 3595 } |
| 3585 | 3596 |
| 3586 | 3597 |
| 3587 void Function::SetName(v8::Handle<v8::String> name) { | 3598 void Function::SetName(v8::Handle<v8::String> name) { |
| 3588 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3599 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3589 ENTER_V8(isolate); | 3600 ENTER_V8(isolate); |
| (...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5038 | 5049 |
| 5039 | 5050 |
| 5040 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) { | 5051 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) { |
| 5041 i::Isolate* isolate = i::Isolate::Current(); | 5052 i::Isolate* isolate = i::Isolate::Current(); |
| 5042 if (IsDeadCheck(isolate, "v8::V8::RemoveMemoryAllocationCallback()")) return; | 5053 if (IsDeadCheck(isolate, "v8::V8::RemoveMemoryAllocationCallback()")) return; |
| 5043 isolate->memory_allocator()->RemoveMemoryAllocationCallback( | 5054 isolate->memory_allocator()->RemoveMemoryAllocationCallback( |
| 5044 callback); | 5055 callback); |
| 5045 } | 5056 } |
| 5046 | 5057 |
| 5047 | 5058 |
| 5059 void V8::AddCallCompletedCallback(CallCompletedCallback callback) { |
| 5060 if (callback == NULL) return; |
| 5061 i::Isolate* isolate = i::Isolate::Current(); |
| 5062 if (IsDeadCheck(isolate, "v8::V8::AddLeaveScriptCallback()")) return; |
| 5063 i::V8::AddCallCompletedCallback(callback); |
| 5064 } |
| 5065 |
| 5066 |
| 5067 void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) { |
| 5068 i::Isolate* isolate = i::Isolate::Current(); |
| 5069 if (IsDeadCheck(isolate, "v8::V8::RemoveLeaveScriptCallback()")) return; |
| 5070 i::V8::RemoveCallCompletedCallback(callback); |
| 5071 } |
| 5072 |
| 5073 |
| 5048 void V8::PauseProfiler() { | 5074 void V8::PauseProfiler() { |
| 5049 i::Isolate* isolate = i::Isolate::Current(); | 5075 i::Isolate* isolate = i::Isolate::Current(); |
| 5050 isolate->logger()->PauseProfiler(); | 5076 isolate->logger()->PauseProfiler(); |
| 5051 } | 5077 } |
| 5052 | 5078 |
| 5053 | 5079 |
| 5054 void V8::ResumeProfiler() { | 5080 void V8::ResumeProfiler() { |
| 5055 i::Isolate* isolate = i::Isolate::Current(); | 5081 i::Isolate* isolate = i::Isolate::Current(); |
| 5056 isolate->logger()->ResumeProfiler(); | 5082 isolate->logger()->ResumeProfiler(); |
| 5057 } | 5083 } |
| (...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6121 | 6147 |
| 6122 | 6148 |
| 6123 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6149 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
| 6124 HandleScopeImplementer* scope_implementer = | 6150 HandleScopeImplementer* scope_implementer = |
| 6125 reinterpret_cast<HandleScopeImplementer*>(storage); | 6151 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 6126 scope_implementer->IterateThis(v); | 6152 scope_implementer->IterateThis(v); |
| 6127 return storage + ArchiveSpacePerThread(); | 6153 return storage + ArchiveSpacePerThread(); |
| 6128 } | 6154 } |
| 6129 | 6155 |
| 6130 } } // namespace v8::internal | 6156 } } // namespace v8::internal |
| OLD | NEW |