OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1895 | 1895 |
1896 v8::Local<Value> v8::TryCatch::StackTrace() const { | 1896 v8::Local<Value> v8::TryCatch::StackTrace() const { |
1897 ASSERT(isolate_ == i::Isolate::Current()); | 1897 ASSERT(isolate_ == i::Isolate::Current()); |
1898 if (HasCaught()) { | 1898 if (HasCaught()) { |
1899 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); | 1899 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); |
1900 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); | 1900 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); |
1901 i::HandleScope scope(isolate_); | 1901 i::HandleScope scope(isolate_); |
1902 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); | 1902 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); |
1903 i::Handle<i::String> name = isolate_->factory()->stack_string(); | 1903 i::Handle<i::String> name = isolate_->factory()->stack_string(); |
1904 if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local<Value>(); | 1904 if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local<Value>(); |
1905 i::Handle<i::Object> value = i::Object::GetProperty(obj, name); | 1905 i::Handle<i::Object> value; |
1906 if (value.is_null()) return v8::Local<Value>(); | 1906 if (!i::Object::GetProperty(obj, name).ToHandle(&value)) { |
| 1907 return v8::Local<Value>(); |
| 1908 } |
1907 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); | 1909 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); |
1908 } else { | 1910 } else { |
1909 return v8::Local<Value>(); | 1911 return v8::Local<Value>(); |
1910 } | 1912 } |
1911 } | 1913 } |
1912 | 1914 |
1913 | 1915 |
1914 v8::Local<v8::Message> v8::TryCatch::Message() const { | 1916 v8::Local<v8::Message> v8::TryCatch::Message() const { |
1915 ASSERT(isolate_ == i::Isolate::Current()); | 1917 ASSERT(isolate_ == i::Isolate::Current()); |
1916 i::Object* message = reinterpret_cast<i::Object*>(message_obj_); | 1918 i::Object* message = reinterpret_cast<i::Object*>(message_obj_); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1991 | 1993 |
1992 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( | 1994 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( |
1993 const char* name, | 1995 const char* name, |
1994 i::Handle<i::Object> recv, | 1996 i::Handle<i::Object> recv, |
1995 int argc, | 1997 int argc, |
1996 i::Handle<i::Object> argv[]) { | 1998 i::Handle<i::Object> argv[]) { |
1997 i::Isolate* isolate = i::Isolate::Current(); | 1999 i::Isolate* isolate = i::Isolate::Current(); |
1998 i::Handle<i::String> fmt_str = | 2000 i::Handle<i::String> fmt_str = |
1999 isolate->factory()->InternalizeUtf8String(name); | 2001 isolate->factory()->InternalizeUtf8String(name); |
2000 i::Handle<i::Object> object_fun = | 2002 i::Handle<i::Object> object_fun = |
2001 i::GlobalObject::GetPropertyNoExceptionThrown( | 2003 i::Object::GetProperty( |
2002 isolate->js_builtins_object(), fmt_str); | 2004 isolate->js_builtins_object(), fmt_str).ToHandleChecked(); |
2003 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(object_fun); | 2005 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(object_fun); |
2004 return i::Execution::Call(isolate, fun, recv, argc, argv); | 2006 return i::Execution::Call(isolate, fun, recv, argc, argv); |
2005 } | 2007 } |
2006 | 2008 |
2007 | 2009 |
2008 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( | 2010 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( |
2009 const char* name, | 2011 const char* name, |
2010 i::Handle<i::Object> data) { | 2012 i::Handle<i::Object> data) { |
2011 i::Handle<i::Object> argv[] = { data }; | 2013 i::Handle<i::Object> argv[] = { data }; |
2012 return CallV8HeapFunction(name, | 2014 return CallV8HeapFunction(name, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2122 | 2124 |
2123 | 2125 |
2124 // --- S t a c k T r a c e --- | 2126 // --- S t a c k T r a c e --- |
2125 | 2127 |
2126 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { | 2128 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { |
2127 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2129 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2128 ENTER_V8(isolate); | 2130 ENTER_V8(isolate); |
2129 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2131 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2130 i::Handle<i::JSArray> self = Utils::OpenHandle(this); | 2132 i::Handle<i::JSArray> self = Utils::OpenHandle(this); |
2131 i::Handle<i::Object> obj = | 2133 i::Handle<i::Object> obj = |
2132 i::Object::GetElementNoExceptionThrown(isolate, self, index); | 2134 i::Object::GetElement(isolate, self, index).ToHandleChecked(); |
2133 i::Handle<i::JSObject> jsobj = i::Handle<i::JSObject>::cast(obj); | 2135 i::Handle<i::JSObject> jsobj = i::Handle<i::JSObject>::cast(obj); |
2134 return scope.Escape(Utils::StackFrameToLocal(jsobj)); | 2136 return scope.Escape(Utils::StackFrameToLocal(jsobj)); |
2135 } | 2137 } |
2136 | 2138 |
2137 | 2139 |
2138 int StackTrace::GetFrameCount() const { | 2140 int StackTrace::GetFrameCount() const { |
2139 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2141 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2140 ENTER_V8(isolate); | 2142 ENTER_V8(isolate); |
2141 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); | 2143 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); |
2142 } | 2144 } |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2437 i::Isolate* isolate = i::Isolate::Current(); | 2439 i::Isolate* isolate = i::Isolate::Current(); |
2438 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2440 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2439 return obj->HasSpecificClassOf(isolate->heap()->Number_string()); | 2441 return obj->HasSpecificClassOf(isolate->heap()->Number_string()); |
2440 } | 2442 } |
2441 | 2443 |
2442 | 2444 |
2443 static i::Object* LookupBuiltin(i::Isolate* isolate, | 2445 static i::Object* LookupBuiltin(i::Isolate* isolate, |
2444 const char* builtin_name) { | 2446 const char* builtin_name) { |
2445 i::Handle<i::String> string = | 2447 i::Handle<i::String> string = |
2446 isolate->factory()->InternalizeUtf8String(builtin_name); | 2448 isolate->factory()->InternalizeUtf8String(builtin_name); |
2447 return *i::GlobalObject::GetPropertyNoExceptionThrown( | 2449 return *i::Object::GetProperty( |
2448 isolate->js_builtins_object(), string); | 2450 isolate->js_builtins_object(), string).ToHandleChecked(); |
2449 } | 2451 } |
2450 | 2452 |
2451 | 2453 |
2452 static bool CheckConstructor(i::Isolate* isolate, | 2454 static bool CheckConstructor(i::Isolate* isolate, |
2453 i::Handle<i::JSObject> obj, | 2455 i::Handle<i::JSObject> obj, |
2454 const char* class_name) { | 2456 const char* class_name) { |
2455 i::Object* constr = obj->map()->constructor(); | 2457 i::Object* constr = obj->map()->constructor(); |
2456 if (!constr->IsJSFunction()) return false; | 2458 if (!constr->IsJSFunction()) return false; |
2457 i::JSFunction* func = i::JSFunction::cast(constr); | 2459 i::JSFunction* func = i::JSFunction::cast(constr); |
2458 return func->shared()->native() && | 2460 return func->shared()->native() && |
(...skipping 4492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6951 v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 6953 v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
6952 i::Debug* isolate_debug = isolate->debug(); | 6954 i::Debug* isolate_debug = isolate->debug(); |
6953 EXCEPTION_PREAMBLE(isolate); | 6955 EXCEPTION_PREAMBLE(isolate); |
6954 has_pending_exception = !isolate_debug->Load(); | 6956 has_pending_exception = !isolate_debug->Load(); |
6955 v8::Local<v8::Value> result; | 6957 v8::Local<v8::Value> result; |
6956 if (!has_pending_exception) { | 6958 if (!has_pending_exception) { |
6957 i::Handle<i::JSObject> debug( | 6959 i::Handle<i::JSObject> debug( |
6958 isolate_debug->debug_context()->global_object()); | 6960 isolate_debug->debug_context()->global_object()); |
6959 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString( | 6961 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString( |
6960 STATIC_ASCII_VECTOR("MakeMirror")); | 6962 STATIC_ASCII_VECTOR("MakeMirror")); |
6961 i::Handle<i::Object> fun_obj = i::Object::GetProperty(debug, name); | 6963 i::Handle<i::Object> fun_obj = |
6962 ASSERT(!fun_obj.is_null()); | 6964 i::Object::GetProperty(debug, name).ToHandleChecked(); |
6963 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); | 6965 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); |
6964 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); | 6966 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); |
6965 const int kArgc = 1; | 6967 const int kArgc = 1; |
6966 v8::Handle<v8::Value> argv[kArgc] = { obj }; | 6968 v8::Handle<v8::Value> argv[kArgc] = { obj }; |
6967 result = v8_fun->Call(Utils::ToLocal(debug), kArgc, argv); | 6969 result = v8_fun->Call(Utils::ToLocal(debug), kArgc, argv); |
6968 has_pending_exception = result.IsEmpty(); | 6970 has_pending_exception = result.IsEmpty(); |
6969 } | 6971 } |
6970 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 6972 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
6971 return scope.Escape(result); | 6973 return scope.Escape(result); |
6972 } | 6974 } |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7648 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7650 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7649 Address callback_address = | 7651 Address callback_address = |
7650 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7652 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7651 VMState<EXTERNAL> state(isolate); | 7653 VMState<EXTERNAL> state(isolate); |
7652 ExternalCallbackScope call_scope(isolate, callback_address); | 7654 ExternalCallbackScope call_scope(isolate, callback_address); |
7653 callback(info); | 7655 callback(info); |
7654 } | 7656 } |
7655 | 7657 |
7656 | 7658 |
7657 } } // namespace v8::internal | 7659 } } // namespace v8::internal |
OLD | NEW |