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 1930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1941 | 1941 |
1942 v8::Local<Value> v8::TryCatch::StackTrace() const { | 1942 v8::Local<Value> v8::TryCatch::StackTrace() const { |
1943 ASSERT(isolate_ == i::Isolate::Current()); | 1943 ASSERT(isolate_ == i::Isolate::Current()); |
1944 if (HasCaught()) { | 1944 if (HasCaught()) { |
1945 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); | 1945 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); |
1946 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); | 1946 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); |
1947 i::HandleScope scope(isolate_); | 1947 i::HandleScope scope(isolate_); |
1948 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); | 1948 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); |
1949 i::Handle<i::String> name = isolate_->factory()->stack_string(); | 1949 i::Handle<i::String> name = isolate_->factory()->stack_string(); |
1950 if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local<Value>(); | 1950 if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local<Value>(); |
1951 i::Handle<i::Object> value = i::Object::GetProperty(obj, name); | 1951 i::Handle<i::Object> value; |
1952 if (value.is_null()) return v8::Local<Value>(); | 1952 if (!i::Object::GetProperty(obj, name).ToHandle(&value)) { |
| 1953 return v8::Local<Value>(); |
| 1954 } |
1953 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); | 1955 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); |
1954 } else { | 1956 } else { |
1955 return v8::Local<Value>(); | 1957 return v8::Local<Value>(); |
1956 } | 1958 } |
1957 } | 1959 } |
1958 | 1960 |
1959 | 1961 |
1960 v8::Local<v8::Message> v8::TryCatch::Message() const { | 1962 v8::Local<v8::Message> v8::TryCatch::Message() const { |
1961 ASSERT(isolate_ == i::Isolate::Current()); | 1963 ASSERT(isolate_ == i::Isolate::Current()); |
1962 i::Object* message = reinterpret_cast<i::Object*>(message_obj_); | 1964 i::Object* message = reinterpret_cast<i::Object*>(message_obj_); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 | 2039 |
2038 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( | 2040 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( |
2039 const char* name, | 2041 const char* name, |
2040 i::Handle<i::Object> recv, | 2042 i::Handle<i::Object> recv, |
2041 int argc, | 2043 int argc, |
2042 i::Handle<i::Object> argv[]) { | 2044 i::Handle<i::Object> argv[]) { |
2043 i::Isolate* isolate = i::Isolate::Current(); | 2045 i::Isolate* isolate = i::Isolate::Current(); |
2044 i::Handle<i::String> fmt_str = | 2046 i::Handle<i::String> fmt_str = |
2045 isolate->factory()->InternalizeUtf8String(name); | 2047 isolate->factory()->InternalizeUtf8String(name); |
2046 i::Handle<i::Object> object_fun = | 2048 i::Handle<i::Object> object_fun = |
2047 i::GlobalObject::GetPropertyNoExceptionThrown( | 2049 i::Object::GetProperty( |
2048 isolate->js_builtins_object(), fmt_str); | 2050 isolate->js_builtins_object(), fmt_str).ToHandleChecked(); |
2049 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(object_fun); | 2051 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(object_fun); |
2050 return i::Execution::Call(isolate, fun, recv, argc, argv); | 2052 return i::Execution::Call(isolate, fun, recv, argc, argv); |
2051 } | 2053 } |
2052 | 2054 |
2053 | 2055 |
2054 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( | 2056 MUST_USE_RESULT static i::MaybeHandle<i::Object> CallV8HeapFunction( |
2055 const char* name, | 2057 const char* name, |
2056 i::Handle<i::Object> data) { | 2058 i::Handle<i::Object> data) { |
2057 i::Handle<i::Object> argv[] = { data }; | 2059 i::Handle<i::Object> argv[] = { data }; |
2058 return CallV8HeapFunction(name, | 2060 return CallV8HeapFunction(name, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2168 | 2170 |
2169 | 2171 |
2170 // --- S t a c k T r a c e --- | 2172 // --- S t a c k T r a c e --- |
2171 | 2173 |
2172 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { | 2174 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { |
2173 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2175 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2174 ENTER_V8(isolate); | 2176 ENTER_V8(isolate); |
2175 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2177 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2176 i::Handle<i::JSArray> self = Utils::OpenHandle(this); | 2178 i::Handle<i::JSArray> self = Utils::OpenHandle(this); |
2177 i::Handle<i::Object> obj = | 2179 i::Handle<i::Object> obj = |
2178 i::Object::GetElementNoExceptionThrown(isolate, self, index); | 2180 i::Object::GetElement(isolate, self, index).ToHandleChecked(); |
2179 i::Handle<i::JSObject> jsobj = i::Handle<i::JSObject>::cast(obj); | 2181 i::Handle<i::JSObject> jsobj = i::Handle<i::JSObject>::cast(obj); |
2180 return scope.Escape(Utils::StackFrameToLocal(jsobj)); | 2182 return scope.Escape(Utils::StackFrameToLocal(jsobj)); |
2181 } | 2183 } |
2182 | 2184 |
2183 | 2185 |
2184 int StackTrace::GetFrameCount() const { | 2186 int StackTrace::GetFrameCount() const { |
2185 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2187 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2186 ENTER_V8(isolate); | 2188 ENTER_V8(isolate); |
2187 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); | 2189 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); |
2188 } | 2190 } |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2483 i::Isolate* isolate = i::Isolate::Current(); | 2485 i::Isolate* isolate = i::Isolate::Current(); |
2484 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2486 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2485 return obj->HasSpecificClassOf(isolate->heap()->Number_string()); | 2487 return obj->HasSpecificClassOf(isolate->heap()->Number_string()); |
2486 } | 2488 } |
2487 | 2489 |
2488 | 2490 |
2489 static i::Object* LookupBuiltin(i::Isolate* isolate, | 2491 static i::Object* LookupBuiltin(i::Isolate* isolate, |
2490 const char* builtin_name) { | 2492 const char* builtin_name) { |
2491 i::Handle<i::String> string = | 2493 i::Handle<i::String> string = |
2492 isolate->factory()->InternalizeUtf8String(builtin_name); | 2494 isolate->factory()->InternalizeUtf8String(builtin_name); |
2493 return *i::GlobalObject::GetPropertyNoExceptionThrown( | 2495 return *i::Object::GetProperty( |
2494 isolate->js_builtins_object(), string); | 2496 isolate->js_builtins_object(), string).ToHandleChecked(); |
2495 } | 2497 } |
2496 | 2498 |
2497 | 2499 |
2498 static bool CheckConstructor(i::Isolate* isolate, | 2500 static bool CheckConstructor(i::Isolate* isolate, |
2499 i::Handle<i::JSObject> obj, | 2501 i::Handle<i::JSObject> obj, |
2500 const char* class_name) { | 2502 const char* class_name) { |
2501 i::Object* constr = obj->map()->constructor(); | 2503 i::Object* constr = obj->map()->constructor(); |
2502 if (!constr->IsJSFunction()) return false; | 2504 if (!constr->IsJSFunction()) return false; |
2503 i::JSFunction* func = i::JSFunction::cast(constr); | 2505 i::JSFunction* func = i::JSFunction::cast(constr); |
2504 return func->shared()->native() && | 2506 return func->shared()->native() && |
(...skipping 4492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6997 v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 6999 v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
6998 i::Debug* isolate_debug = isolate->debug(); | 7000 i::Debug* isolate_debug = isolate->debug(); |
6999 EXCEPTION_PREAMBLE(isolate); | 7001 EXCEPTION_PREAMBLE(isolate); |
7000 has_pending_exception = !isolate_debug->Load(); | 7002 has_pending_exception = !isolate_debug->Load(); |
7001 v8::Local<v8::Value> result; | 7003 v8::Local<v8::Value> result; |
7002 if (!has_pending_exception) { | 7004 if (!has_pending_exception) { |
7003 i::Handle<i::JSObject> debug( | 7005 i::Handle<i::JSObject> debug( |
7004 isolate_debug->debug_context()->global_object()); | 7006 isolate_debug->debug_context()->global_object()); |
7005 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString( | 7007 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString( |
7006 STATIC_ASCII_VECTOR("MakeMirror")); | 7008 STATIC_ASCII_VECTOR("MakeMirror")); |
7007 i::Handle<i::Object> fun_obj = i::Object::GetProperty(debug, name); | 7009 i::Handle<i::Object> fun_obj = |
7008 ASSERT(!fun_obj.is_null()); | 7010 i::Object::GetProperty(debug, name).ToHandleChecked(); |
7009 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); | 7011 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); |
7010 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); | 7012 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); |
7011 const int kArgc = 1; | 7013 const int kArgc = 1; |
7012 v8::Handle<v8::Value> argv[kArgc] = { obj }; | 7014 v8::Handle<v8::Value> argv[kArgc] = { obj }; |
7013 result = v8_fun->Call(Utils::ToLocal(debug), kArgc, argv); | 7015 result = v8_fun->Call(Utils::ToLocal(debug), kArgc, argv); |
7014 has_pending_exception = result.IsEmpty(); | 7016 has_pending_exception = result.IsEmpty(); |
7015 } | 7017 } |
7016 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 7018 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
7017 return scope.Escape(result); | 7019 return scope.Escape(result); |
7018 } | 7020 } |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7694 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7696 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7695 Address callback_address = | 7697 Address callback_address = |
7696 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7698 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7697 VMState<EXTERNAL> state(isolate); | 7699 VMState<EXTERNAL> state(isolate); |
7698 ExternalCallbackScope call_scope(isolate, callback_address); | 7700 ExternalCallbackScope call_scope(isolate, callback_address); |
7699 callback(info); | 7701 callback(info); |
7700 } | 7702 } |
7701 | 7703 |
7702 | 7704 |
7703 } } // namespace v8::internal | 7705 } } // namespace v8::internal |
OLD | NEW |