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 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1780 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); | 1780 if (!stackFramesObj->IsJSArray()) return v8::Handle<v8::StackTrace>(); |
1781 i::Handle<i::JSArray> stackTrace = | 1781 i::Handle<i::JSArray> stackTrace = |
1782 i::Handle<i::JSArray>::cast(stackFramesObj); | 1782 i::Handle<i::JSArray>::cast(stackFramesObj); |
1783 return scope.Close(Utils::StackTraceToLocal(stackTrace)); | 1783 return scope.Close(Utils::StackTraceToLocal(stackTrace)); |
1784 } | 1784 } |
1785 | 1785 |
1786 | 1786 |
1787 static i::Handle<i::Object> CallV8HeapFunction(const char* name, | 1787 static i::Handle<i::Object> CallV8HeapFunction(const char* name, |
1788 i::Handle<i::Object> recv, | 1788 i::Handle<i::Object> recv, |
1789 int argc, | 1789 int argc, |
1790 i::Object** argv[], | 1790 i::Handle<i::Object> argv[], |
1791 bool* has_pending_exception) { | 1791 bool* has_pending_exception) { |
1792 i::Isolate* isolate = i::Isolate::Current(); | 1792 i::Isolate* isolate = i::Isolate::Current(); |
1793 i::Handle<i::String> fmt_str = isolate->factory()->LookupAsciiSymbol(name); | 1793 i::Handle<i::String> fmt_str = isolate->factory()->LookupAsciiSymbol(name); |
1794 i::Object* object_fun = | 1794 i::Object* object_fun = |
1795 isolate->js_builtins_object()->GetPropertyNoExceptionThrown(*fmt_str); | 1795 isolate->js_builtins_object()->GetPropertyNoExceptionThrown(*fmt_str); |
1796 i::Handle<i::JSFunction> fun = | 1796 i::Handle<i::JSFunction> fun = |
1797 i::Handle<i::JSFunction>(i::JSFunction::cast(object_fun)); | 1797 i::Handle<i::JSFunction>(i::JSFunction::cast(object_fun)); |
1798 i::Handle<i::Object> value = | 1798 i::Handle<i::Object> value = |
1799 i::Execution::Call(fun, recv, argc, argv, has_pending_exception); | 1799 i::Execution::Call(fun, recv, argc, argv, has_pending_exception); |
1800 return value; | 1800 return value; |
1801 } | 1801 } |
1802 | 1802 |
1803 | 1803 |
1804 static i::Handle<i::Object> CallV8HeapFunction(const char* name, | 1804 static i::Handle<i::Object> CallV8HeapFunction(const char* name, |
1805 i::Handle<i::Object> data, | 1805 i::Handle<i::Object> data, |
1806 bool* has_pending_exception) { | 1806 bool* has_pending_exception) { |
1807 i::Object** argv[1] = { data.location() }; | 1807 i::Handle<i::Object> argv[] = { data }; |
1808 return CallV8HeapFunction(name, | 1808 return CallV8HeapFunction(name, |
1809 i::Isolate::Current()->js_builtins_object(), | 1809 i::Isolate::Current()->js_builtins_object(), |
1810 1, | 1810 ARRAY_SIZE(argv), |
1811 argv, | 1811 argv, |
1812 has_pending_exception); | 1812 has_pending_exception); |
1813 } | 1813 } |
1814 | 1814 |
1815 | 1815 |
1816 int Message::GetLineNumber() const { | 1816 int Message::GetLineNumber() const { |
1817 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1817 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1818 ON_BAILOUT(isolate, "v8::Message::GetLineNumber()", return kNoLineNumberInfo); | 1818 ON_BAILOUT(isolate, "v8::Message::GetLineNumber()", return kNoLineNumberInfo); |
1819 ENTER_V8(isolate); | 1819 ENTER_V8(isolate); |
1820 i::HandleScope scope(isolate); | 1820 i::HandleScope scope(isolate); |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2620 LOG_API(isolate, "Equals"); | 2620 LOG_API(isolate, "Equals"); |
2621 ENTER_V8(isolate); | 2621 ENTER_V8(isolate); |
2622 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2622 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2623 i::Handle<i::Object> other = Utils::OpenHandle(*that); | 2623 i::Handle<i::Object> other = Utils::OpenHandle(*that); |
2624 // If both obj and other are JSObjects, we'd better compare by identity | 2624 // If both obj and other are JSObjects, we'd better compare by identity |
2625 // immediately when going into JS builtin. The reason is Invoke | 2625 // immediately when going into JS builtin. The reason is Invoke |
2626 // would overwrite global object receiver with global proxy. | 2626 // would overwrite global object receiver with global proxy. |
2627 if (obj->IsJSObject() && other->IsJSObject()) { | 2627 if (obj->IsJSObject() && other->IsJSObject()) { |
2628 return *obj == *other; | 2628 return *obj == *other; |
2629 } | 2629 } |
2630 i::Object** args[1] = { other.location() }; | 2630 i::Handle<i::Object> args[] = { other }; |
2631 EXCEPTION_PREAMBLE(isolate); | 2631 EXCEPTION_PREAMBLE(isolate); |
2632 i::Handle<i::Object> result = | 2632 i::Handle<i::Object> result = |
2633 CallV8HeapFunction("EQUALS", obj, 1, args, &has_pending_exception); | 2633 CallV8HeapFunction("EQUALS", obj, ARRAY_SIZE(args), args, |
| 2634 &has_pending_exception); |
2634 EXCEPTION_BAILOUT_CHECK(isolate, false); | 2635 EXCEPTION_BAILOUT_CHECK(isolate, false); |
2635 return *result == i::Smi::FromInt(i::EQUAL); | 2636 return *result == i::Smi::FromInt(i::EQUAL); |
2636 } | 2637 } |
2637 | 2638 |
2638 | 2639 |
2639 bool Value::StrictEquals(Handle<Value> that) const { | 2640 bool Value::StrictEquals(Handle<Value> that) const { |
2640 i::Isolate* isolate = i::Isolate::Current(); | 2641 i::Isolate* isolate = i::Isolate::Current(); |
2641 if (IsDeadCheck(isolate, "v8::Value::StrictEquals()") | 2642 if (IsDeadCheck(isolate, "v8::Value::StrictEquals()") |
2642 || EmptyCheck("v8::Value::StrictEquals()", this) | 2643 || EmptyCheck("v8::Value::StrictEquals()", this) |
2643 || EmptyCheck("v8::Value::StrictEquals()", that)) { | 2644 || EmptyCheck("v8::Value::StrictEquals()", that)) { |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3445 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3446 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3446 ON_BAILOUT(isolate, "v8::Object::IsCallable()", return false); | 3447 ON_BAILOUT(isolate, "v8::Object::IsCallable()", return false); |
3447 ENTER_V8(isolate); | 3448 ENTER_V8(isolate); |
3448 i::HandleScope scope(isolate); | 3449 i::HandleScope scope(isolate); |
3449 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 3450 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
3450 if (obj->IsJSFunction()) return true; | 3451 if (obj->IsJSFunction()) return true; |
3451 return i::Execution::GetFunctionDelegate(obj)->IsJSFunction(); | 3452 return i::Execution::GetFunctionDelegate(obj)->IsJSFunction(); |
3452 } | 3453 } |
3453 | 3454 |
3454 | 3455 |
3455 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv, int argc, | 3456 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Object> recv, |
| 3457 int argc, |
3456 v8::Handle<v8::Value> argv[]) { | 3458 v8::Handle<v8::Value> argv[]) { |
3457 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3459 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3458 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()", | 3460 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()", |
3459 return Local<v8::Value>()); | 3461 return Local<v8::Value>()); |
3460 LOG_API(isolate, "Object::CallAsFunction"); | 3462 LOG_API(isolate, "Object::CallAsFunction"); |
3461 ENTER_V8(isolate); | 3463 ENTER_V8(isolate); |
3462 i::HandleScope scope(isolate); | 3464 i::HandleScope scope(isolate); |
3463 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 3465 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
3464 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); | 3466 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); |
3465 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 3467 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
3466 i::Object*** args = reinterpret_cast<i::Object***>(argv); | 3468 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
3467 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>(); | 3469 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>(); |
3468 if (obj->IsJSFunction()) { | 3470 if (obj->IsJSFunction()) { |
3469 fun = i::Handle<i::JSFunction>::cast(obj); | 3471 fun = i::Handle<i::JSFunction>::cast(obj); |
3470 } else { | 3472 } else { |
3471 EXCEPTION_PREAMBLE(isolate); | 3473 EXCEPTION_PREAMBLE(isolate); |
3472 i::Handle<i::Object> delegate = | 3474 i::Handle<i::Object> delegate = |
3473 i::Execution::TryGetFunctionDelegate(obj, &has_pending_exception); | 3475 i::Execution::TryGetFunctionDelegate(obj, &has_pending_exception); |
3474 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 3476 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
3475 fun = i::Handle<i::JSFunction>::cast(delegate); | 3477 fun = i::Handle<i::JSFunction>::cast(delegate); |
3476 recv_obj = obj; | 3478 recv_obj = obj; |
3477 } | 3479 } |
3478 EXCEPTION_PREAMBLE(isolate); | 3480 EXCEPTION_PREAMBLE(isolate); |
3479 i::Handle<i::Object> returned = | 3481 i::Handle<i::Object> returned = |
3480 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); | 3482 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); |
3481 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 3483 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
3482 return Utils::ToLocal(scope.CloseAndEscape(returned)); | 3484 return Utils::ToLocal(scope.CloseAndEscape(returned)); |
3483 } | 3485 } |
3484 | 3486 |
3485 | 3487 |
3486 Local<v8::Value> Object::CallAsConstructor(int argc, | 3488 Local<v8::Value> Object::CallAsConstructor(int argc, |
3487 v8::Handle<v8::Value> argv[]) { | 3489 v8::Handle<v8::Value> argv[]) { |
3488 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3490 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3489 ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()", | 3491 ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()", |
3490 return Local<v8::Object>()); | 3492 return Local<v8::Object>()); |
3491 LOG_API(isolate, "Object::CallAsConstructor"); | 3493 LOG_API(isolate, "Object::CallAsConstructor"); |
3492 ENTER_V8(isolate); | 3494 ENTER_V8(isolate); |
3493 i::HandleScope scope(isolate); | 3495 i::HandleScope scope(isolate); |
3494 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 3496 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
3495 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 3497 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
3496 i::Object*** args = reinterpret_cast<i::Object***>(argv); | 3498 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
3497 if (obj->IsJSFunction()) { | 3499 if (obj->IsJSFunction()) { |
3498 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj); | 3500 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj); |
3499 EXCEPTION_PREAMBLE(isolate); | 3501 EXCEPTION_PREAMBLE(isolate); |
3500 i::Handle<i::Object> returned = | 3502 i::Handle<i::Object> returned = |
3501 i::Execution::New(fun, argc, args, &has_pending_exception); | 3503 i::Execution::New(fun, argc, args, &has_pending_exception); |
3502 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); | 3504 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); |
3503 return Utils::ToLocal(scope.CloseAndEscape( | 3505 return Utils::ToLocal(scope.CloseAndEscape( |
3504 i::Handle<i::JSObject>::cast(returned))); | 3506 i::Handle<i::JSObject>::cast(returned))); |
3505 } | 3507 } |
3506 EXCEPTION_PREAMBLE(isolate); | 3508 EXCEPTION_PREAMBLE(isolate); |
(...skipping 21 matching lines...) Expand all Loading... |
3528 Local<v8::Object> Function::NewInstance(int argc, | 3530 Local<v8::Object> Function::NewInstance(int argc, |
3529 v8::Handle<v8::Value> argv[]) const { | 3531 v8::Handle<v8::Value> argv[]) const { |
3530 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3532 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3531 ON_BAILOUT(isolate, "v8::Function::NewInstance()", | 3533 ON_BAILOUT(isolate, "v8::Function::NewInstance()", |
3532 return Local<v8::Object>()); | 3534 return Local<v8::Object>()); |
3533 LOG_API(isolate, "Function::NewInstance"); | 3535 LOG_API(isolate, "Function::NewInstance"); |
3534 ENTER_V8(isolate); | 3536 ENTER_V8(isolate); |
3535 HandleScope scope; | 3537 HandleScope scope; |
3536 i::Handle<i::JSFunction> function = Utils::OpenHandle(this); | 3538 i::Handle<i::JSFunction> function = Utils::OpenHandle(this); |
3537 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 3539 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
3538 i::Object*** args = reinterpret_cast<i::Object***>(argv); | 3540 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
3539 EXCEPTION_PREAMBLE(isolate); | 3541 EXCEPTION_PREAMBLE(isolate); |
3540 i::Handle<i::Object> returned = | 3542 i::Handle<i::Object> returned = |
3541 i::Execution::New(function, argc, args, &has_pending_exception); | 3543 i::Execution::New(function, argc, args, &has_pending_exception); |
3542 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); | 3544 EXCEPTION_BAILOUT_CHECK(isolate, Local<v8::Object>()); |
3543 return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); | 3545 return scope.Close(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); |
3544 } | 3546 } |
3545 | 3547 |
3546 | 3548 |
3547 Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc, | 3549 Local<v8::Value> Function::Call(v8::Handle<v8::Object> recv, int argc, |
3548 v8::Handle<v8::Value> argv[]) { | 3550 v8::Handle<v8::Value> argv[]) { |
3549 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3551 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3550 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>()); | 3552 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>()); |
3551 LOG_API(isolate, "Function::Call"); | 3553 LOG_API(isolate, "Function::Call"); |
3552 ENTER_V8(isolate); | 3554 ENTER_V8(isolate); |
3553 i::Object* raw_result = NULL; | 3555 i::Object* raw_result = NULL; |
3554 { | 3556 { |
3555 i::HandleScope scope(isolate); | 3557 i::HandleScope scope(isolate); |
3556 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); | 3558 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); |
3557 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); | 3559 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); |
3558 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 3560 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
3559 i::Object*** args = reinterpret_cast<i::Object***>(argv); | 3561 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
3560 EXCEPTION_PREAMBLE(isolate); | 3562 EXCEPTION_PREAMBLE(isolate); |
3561 i::Handle<i::Object> returned = | 3563 i::Handle<i::Object> returned = |
3562 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); | 3564 i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception); |
3563 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); | 3565 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); |
3564 raw_result = *returned; | 3566 raw_result = *returned; |
3565 } | 3567 } |
3566 i::Handle<i::Object> result(raw_result); | 3568 i::Handle<i::Object> result(raw_result); |
3567 return Utils::ToLocal(result); | 3569 return Utils::ToLocal(result); |
3568 } | 3570 } |
3569 | 3571 |
(...skipping 2492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6062 | 6064 |
6063 | 6065 |
6064 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6066 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
6065 HandleScopeImplementer* scope_implementer = | 6067 HandleScopeImplementer* scope_implementer = |
6066 reinterpret_cast<HandleScopeImplementer*>(storage); | 6068 reinterpret_cast<HandleScopeImplementer*>(storage); |
6067 scope_implementer->IterateThis(v); | 6069 scope_implementer->IterateThis(v); |
6068 return storage + ArchiveSpacePerThread(); | 6070 return storage + ArchiveSpacePerThread(); |
6069 } | 6071 } |
6070 | 6072 |
6071 } } // namespace v8::internal | 6073 } } // namespace v8::internal |
OLD | NEW |