OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 | 1667 |
1668 Local<Value> Script::Run() { | 1668 Local<Value> Script::Run() { |
1669 i::Handle<i::Object> obj = Utils::OpenHandle(this, true); | 1669 i::Handle<i::Object> obj = Utils::OpenHandle(this, true); |
1670 // If execution is terminating, Compile(..)->Run() requires this | 1670 // If execution is terminating, Compile(..)->Run() requires this |
1671 // check. | 1671 // check. |
1672 if (obj.is_null()) return Local<Value>(); | 1672 if (obj.is_null()) return Local<Value>(); |
1673 i::Isolate* isolate = i::Handle<i::HeapObject>::cast(obj)->GetIsolate(); | 1673 i::Isolate* isolate = i::Handle<i::HeapObject>::cast(obj)->GetIsolate(); |
1674 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); | 1674 ON_BAILOUT(isolate, "v8::Script::Run()", return Local<Value>()); |
1675 LOG_API(isolate, "Script::Run"); | 1675 LOG_API(isolate, "Script::Run"); |
1676 ENTER_V8(isolate); | 1676 ENTER_V8(isolate); |
1677 i::Logger::TimerEventScope timer_scope( | 1677 TimerEventScope<TimerEventExecute> timer_scope(isolate); |
1678 isolate, i::Logger::TimerEventScope::v8_execute); | |
1679 i::HandleScope scope(isolate); | 1678 i::HandleScope scope(isolate); |
1680 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj); | 1679 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj); |
1681 EXCEPTION_PREAMBLE(isolate); | 1680 EXCEPTION_PREAMBLE(isolate); |
1682 i::Handle<i::Object> receiver(isolate->global_proxy(), isolate); | 1681 i::Handle<i::Object> receiver(isolate->global_proxy(), isolate); |
1683 i::Handle<i::Object> result; | 1682 i::Handle<i::Object> result; |
1684 has_pending_exception = !i::Execution::Call( | 1683 has_pending_exception = !i::Execution::Call( |
1685 isolate, fun, receiver, 0, NULL).ToHandle(&result); | 1684 isolate, fun, receiver, 0, NULL).ToHandle(&result); |
1686 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>()); | 1685 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Value>()); |
1687 return Utils::ToLocal(scope.CloseAndEscape(result)); | 1686 return Utils::ToLocal(scope.CloseAndEscape(result)); |
1688 } | 1687 } |
(...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3877 | 3876 |
3878 | 3877 |
3879 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Value> recv, | 3878 Local<v8::Value> Object::CallAsFunction(v8::Handle<v8::Value> recv, |
3880 int argc, | 3879 int argc, |
3881 v8::Handle<v8::Value> argv[]) { | 3880 v8::Handle<v8::Value> argv[]) { |
3882 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3881 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3883 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()", | 3882 ON_BAILOUT(isolate, "v8::Object::CallAsFunction()", |
3884 return Local<v8::Value>()); | 3883 return Local<v8::Value>()); |
3885 LOG_API(isolate, "Object::CallAsFunction"); | 3884 LOG_API(isolate, "Object::CallAsFunction"); |
3886 ENTER_V8(isolate); | 3885 ENTER_V8(isolate); |
3887 i::Logger::TimerEventScope timer_scope( | 3886 TimerEventScope<TimerEventExecute> timer_scope(isolate); |
3888 isolate, i::Logger::TimerEventScope::v8_execute); | |
3889 i::HandleScope scope(isolate); | 3887 i::HandleScope scope(isolate); |
3890 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 3888 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
3891 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); | 3889 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); |
3892 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 3890 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
3893 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 3891 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
3894 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>(); | 3892 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>(); |
3895 if (obj->IsJSFunction()) { | 3893 if (obj->IsJSFunction()) { |
3896 fun = i::Handle<i::JSFunction>::cast(obj); | 3894 fun = i::Handle<i::JSFunction>::cast(obj); |
3897 } else { | 3895 } else { |
3898 EXCEPTION_PREAMBLE(isolate); | 3896 EXCEPTION_PREAMBLE(isolate); |
(...skipping 13 matching lines...) Expand all Loading... |
3912 } | 3910 } |
3913 | 3911 |
3914 | 3912 |
3915 Local<v8::Value> Object::CallAsConstructor(int argc, | 3913 Local<v8::Value> Object::CallAsConstructor(int argc, |
3916 v8::Handle<v8::Value> argv[]) { | 3914 v8::Handle<v8::Value> argv[]) { |
3917 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3915 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3918 ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()", | 3916 ON_BAILOUT(isolate, "v8::Object::CallAsConstructor()", |
3919 return Local<v8::Object>()); | 3917 return Local<v8::Object>()); |
3920 LOG_API(isolate, "Object::CallAsConstructor"); | 3918 LOG_API(isolate, "Object::CallAsConstructor"); |
3921 ENTER_V8(isolate); | 3919 ENTER_V8(isolate); |
3922 i::Logger::TimerEventScope timer_scope( | 3920 TimerEventScope<TimerEventExecute> timer_scope(isolate); |
3923 isolate, i::Logger::TimerEventScope::v8_execute); | |
3924 i::HandleScope scope(isolate); | 3921 i::HandleScope scope(isolate); |
3925 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); | 3922 i::Handle<i::JSObject> obj = Utils::OpenHandle(this); |
3926 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 3923 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
3927 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 3924 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
3928 if (obj->IsJSFunction()) { | 3925 if (obj->IsJSFunction()) { |
3929 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj); | 3926 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj); |
3930 EXCEPTION_PREAMBLE(isolate); | 3927 EXCEPTION_PREAMBLE(isolate); |
3931 i::Handle<i::Object> returned; | 3928 i::Handle<i::Object> returned; |
3932 has_pending_exception = !i::Execution::New( | 3929 has_pending_exception = !i::Execution::New( |
3933 fun, argc, args).ToHandle(&returned); | 3930 fun, argc, args).ToHandle(&returned); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3972 } | 3969 } |
3973 | 3970 |
3974 | 3971 |
3975 Local<v8::Object> Function::NewInstance(int argc, | 3972 Local<v8::Object> Function::NewInstance(int argc, |
3976 v8::Handle<v8::Value> argv[]) const { | 3973 v8::Handle<v8::Value> argv[]) const { |
3977 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3974 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3978 ON_BAILOUT(isolate, "v8::Function::NewInstance()", | 3975 ON_BAILOUT(isolate, "v8::Function::NewInstance()", |
3979 return Local<v8::Object>()); | 3976 return Local<v8::Object>()); |
3980 LOG_API(isolate, "Function::NewInstance"); | 3977 LOG_API(isolate, "Function::NewInstance"); |
3981 ENTER_V8(isolate); | 3978 ENTER_V8(isolate); |
3982 i::Logger::TimerEventScope timer_scope( | 3979 TimerEventScope<TimerEventExecute> timer_scope(isolate); |
3983 isolate, i::Logger::TimerEventScope::v8_execute); | |
3984 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 3980 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
3985 i::Handle<i::JSFunction> function = Utils::OpenHandle(this); | 3981 i::Handle<i::JSFunction> function = Utils::OpenHandle(this); |
3986 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 3982 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
3987 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 3983 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
3988 EXCEPTION_PREAMBLE(isolate); | 3984 EXCEPTION_PREAMBLE(isolate); |
3989 i::Handle<i::Object> returned; | 3985 i::Handle<i::Object> returned; |
3990 has_pending_exception = !i::Execution::New( | 3986 has_pending_exception = !i::Execution::New( |
3991 function, argc, args).ToHandle(&returned); | 3987 function, argc, args).ToHandle(&returned); |
3992 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>()); | 3988 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<v8::Object>()); |
3993 return scope.Escape(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); | 3989 return scope.Escape(Utils::ToLocal(i::Handle<i::JSObject>::cast(returned))); |
3994 } | 3990 } |
3995 | 3991 |
3996 | 3992 |
3997 Local<v8::Value> Function::Call(v8::Handle<v8::Value> recv, int argc, | 3993 Local<v8::Value> Function::Call(v8::Handle<v8::Value> recv, int argc, |
3998 v8::Handle<v8::Value> argv[]) { | 3994 v8::Handle<v8::Value> argv[]) { |
3999 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3995 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
4000 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>()); | 3996 ON_BAILOUT(isolate, "v8::Function::Call()", return Local<v8::Value>()); |
4001 LOG_API(isolate, "Function::Call"); | 3997 LOG_API(isolate, "Function::Call"); |
4002 ENTER_V8(isolate); | 3998 ENTER_V8(isolate); |
4003 i::Logger::TimerEventScope timer_scope( | 3999 TimerEventScope<TimerEventExecute> timer_scope(isolate); |
4004 isolate, i::Logger::TimerEventScope::v8_execute); | |
4005 i::HandleScope scope(isolate); | 4000 i::HandleScope scope(isolate); |
4006 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); | 4001 i::Handle<i::JSFunction> fun = Utils::OpenHandle(this); |
4007 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); | 4002 i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv); |
4008 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); | 4003 STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**)); |
4009 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); | 4004 i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv); |
4010 EXCEPTION_PREAMBLE(isolate); | 4005 EXCEPTION_PREAMBLE(isolate); |
4011 i::Handle<i::Object> returned; | 4006 i::Handle<i::Object> returned; |
4012 has_pending_exception = !i::Execution::Call( | 4007 has_pending_exception = !i::Execution::Call( |
4013 isolate, fun, recv_obj, argc, args, true).ToHandle(&returned); | 4008 isolate, fun, recv_obj, argc, args, true).ToHandle(&returned); |
4014 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Object>()); | 4009 EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local<Object>()); |
(...skipping 3614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7629 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7624 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7630 Address callback_address = | 7625 Address callback_address = |
7631 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7626 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7632 VMState<EXTERNAL> state(isolate); | 7627 VMState<EXTERNAL> state(isolate); |
7633 ExternalCallbackScope call_scope(isolate, callback_address); | 7628 ExternalCallbackScope call_scope(isolate, callback_address); |
7634 callback(info); | 7629 callback(info); |
7635 } | 7630 } |
7636 | 7631 |
7637 | 7632 |
7638 } } // namespace v8::internal | 7633 } } // namespace v8::internal |
OLD | NEW |