Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: src/api.cc

Issue 233233004: Handlify GetProperty. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | src/objects.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1935 matching lines...) Expand 10 before | Expand all | Expand 10 after
1946 1946
1947 v8::Local<Value> v8::TryCatch::StackTrace() const { 1947 v8::Local<Value> v8::TryCatch::StackTrace() const {
1948 ASSERT(isolate_ == i::Isolate::Current()); 1948 ASSERT(isolate_ == i::Isolate::Current());
1949 if (HasCaught()) { 1949 if (HasCaught()) {
1950 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); 1950 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_);
1951 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); 1951 if (!raw_obj->IsJSObject()) return v8::Local<Value>();
1952 i::HandleScope scope(isolate_); 1952 i::HandleScope scope(isolate_);
1953 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); 1953 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_);
1954 i::Handle<i::String> name = isolate_->factory()->stack_string(); 1954 i::Handle<i::String> name = isolate_->factory()->stack_string();
1955 if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local<Value>(); 1955 if (!i::JSReceiver::HasProperty(obj, name)) return v8::Local<Value>();
1956 i::Handle<i::Object> value = i::Object::GetProperty(obj, name); 1956 i::Handle<i::Object> value;
1957 if (value.is_null()) return v8::Local<Value>(); 1957 if (!i::Object::GetProperty(obj, name).ToHandle(&value)) {
1958 return v8::Local<Value>();
1959 }
1958 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); 1960 return v8::Utils::ToLocal(scope.CloseAndEscape(value));
1959 } else { 1961 } else {
1960 return v8::Local<Value>(); 1962 return v8::Local<Value>();
1961 } 1963 }
1962 } 1964 }
1963 1965
1964 1966
1965 v8::Local<v8::Message> v8::TryCatch::Message() const { 1967 v8::Local<v8::Message> v8::TryCatch::Message() const {
1966 ASSERT(isolate_ == i::Isolate::Current()); 1968 ASSERT(isolate_ == i::Isolate::Current());
1967 i::Object* message = reinterpret_cast<i::Object*>(message_obj_); 1969 i::Object* message = reinterpret_cast<i::Object*>(message_obj_);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 2044
2043 static i::Handle<i::Object> CallV8HeapFunction(const char* name, 2045 static i::Handle<i::Object> CallV8HeapFunction(const char* name,
2044 i::Handle<i::Object> recv, 2046 i::Handle<i::Object> recv,
2045 int argc, 2047 int argc,
2046 i::Handle<i::Object> argv[], 2048 i::Handle<i::Object> argv[],
2047 bool* has_pending_exception) { 2049 bool* has_pending_exception) {
2048 i::Isolate* isolate = i::Isolate::Current(); 2050 i::Isolate* isolate = i::Isolate::Current();
2049 i::Handle<i::String> fmt_str = 2051 i::Handle<i::String> fmt_str =
2050 isolate->factory()->InternalizeUtf8String(name); 2052 isolate->factory()->InternalizeUtf8String(name);
2051 i::Handle<i::Object> object_fun = 2053 i::Handle<i::Object> object_fun =
2052 i::GlobalObject::GetPropertyNoExceptionThrown( 2054 i::Object::GetProperty(
2053 isolate->js_builtins_object(), fmt_str); 2055 isolate->js_builtins_object(), fmt_str).ToHandleChecked();
2054 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(object_fun); 2056 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(object_fun);
2055 i::Handle<i::Object> value = i::Execution::Call( 2057 i::Handle<i::Object> value = i::Execution::Call(
2056 isolate, fun, recv, argc, argv, has_pending_exception); 2058 isolate, fun, recv, argc, argv, has_pending_exception);
2057 return value; 2059 return value;
2058 } 2060 }
2059 2061
2060 2062
2061 static i::Handle<i::Object> CallV8HeapFunction(const char* name, 2063 static i::Handle<i::Object> CallV8HeapFunction(const char* name,
2062 i::Handle<i::Object> data, 2064 i::Handle<i::Object> data,
2063 bool* has_pending_exception) { 2065 bool* has_pending_exception) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 2180
2179 2181
2180 // --- S t a c k T r a c e --- 2182 // --- S t a c k T r a c e ---
2181 2183
2182 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const { 2184 Local<StackFrame> StackTrace::GetFrame(uint32_t index) const {
2183 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2185 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2184 ENTER_V8(isolate); 2186 ENTER_V8(isolate);
2185 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); 2187 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
2186 i::Handle<i::JSArray> self = Utils::OpenHandle(this); 2188 i::Handle<i::JSArray> self = Utils::OpenHandle(this);
2187 i::Handle<i::Object> obj = 2189 i::Handle<i::Object> obj =
2188 i::Object::GetElementNoExceptionThrown(isolate, self, index); 2190 i::Object::GetElement(isolate, self, index).ToHandleChecked();
2189 i::Handle<i::JSObject> jsobj = i::Handle<i::JSObject>::cast(obj); 2191 i::Handle<i::JSObject> jsobj = i::Handle<i::JSObject>::cast(obj);
2190 return scope.Escape(Utils::StackFrameToLocal(jsobj)); 2192 return scope.Escape(Utils::StackFrameToLocal(jsobj));
2191 } 2193 }
2192 2194
2193 2195
2194 int StackTrace::GetFrameCount() const { 2196 int StackTrace::GetFrameCount() const {
2195 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 2197 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
2196 ENTER_V8(isolate); 2198 ENTER_V8(isolate);
2197 return i::Smi::cast(Utils::OpenHandle(this)->length())->value(); 2199 return i::Smi::cast(Utils::OpenHandle(this)->length())->value();
2198 } 2200 }
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 i::Isolate* isolate = i::Isolate::Current(); 2495 i::Isolate* isolate = i::Isolate::Current();
2494 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2496 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2495 return obj->HasSpecificClassOf(isolate->heap()->Number_string()); 2497 return obj->HasSpecificClassOf(isolate->heap()->Number_string());
2496 } 2498 }
2497 2499
2498 2500
2499 static i::Object* LookupBuiltin(i::Isolate* isolate, 2501 static i::Object* LookupBuiltin(i::Isolate* isolate,
2500 const char* builtin_name) { 2502 const char* builtin_name) {
2501 i::Handle<i::String> string = 2503 i::Handle<i::String> string =
2502 isolate->factory()->InternalizeUtf8String(builtin_name); 2504 isolate->factory()->InternalizeUtf8String(builtin_name);
2503 return *i::GlobalObject::GetPropertyNoExceptionThrown( 2505 return *i::Object::GetProperty(
2504 isolate->js_builtins_object(), string); 2506 isolate->js_builtins_object(), string).ToHandleChecked();
2505 } 2507 }
2506 2508
2507 2509
2508 static bool CheckConstructor(i::Isolate* isolate, 2510 static bool CheckConstructor(i::Isolate* isolate,
2509 i::Handle<i::JSObject> obj, 2511 i::Handle<i::JSObject> obj,
2510 const char* class_name) { 2512 const char* class_name) {
2511 i::Object* constr = obj->map()->constructor(); 2513 i::Object* constr = obj->map()->constructor();
2512 if (!constr->IsJSFunction()) return false; 2514 if (!constr->IsJSFunction()) return false;
2513 i::JSFunction* func = i::JSFunction::cast(constr); 2515 i::JSFunction* func = i::JSFunction::cast(constr);
2514 return func->shared()->native() && 2516 return func->shared()->native() &&
(...skipping 4479 matching lines...) Expand 10 before | Expand all | Expand 10 after
6994 v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); 6996 v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
6995 i::Debug* isolate_debug = isolate->debug(); 6997 i::Debug* isolate_debug = isolate->debug();
6996 EXCEPTION_PREAMBLE(isolate); 6998 EXCEPTION_PREAMBLE(isolate);
6997 has_pending_exception = !isolate_debug->Load(); 6999 has_pending_exception = !isolate_debug->Load();
6998 v8::Local<v8::Value> result; 7000 v8::Local<v8::Value> result;
6999 if (!has_pending_exception) { 7001 if (!has_pending_exception) {
7000 i::Handle<i::JSObject> debug( 7002 i::Handle<i::JSObject> debug(
7001 isolate_debug->debug_context()->global_object()); 7003 isolate_debug->debug_context()->global_object());
7002 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString( 7004 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString(
7003 STATIC_ASCII_VECTOR("MakeMirror")); 7005 STATIC_ASCII_VECTOR("MakeMirror"));
7004 i::Handle<i::Object> fun_obj = i::Object::GetProperty(debug, name); 7006 i::Handle<i::Object> fun_obj =
7005 ASSERT(!fun_obj.is_null()); 7007 i::Object::GetProperty(debug, name).ToHandleChecked();
7006 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj); 7008 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj);
7007 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun); 7009 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun);
7008 const int kArgc = 1; 7010 const int kArgc = 1;
7009 v8::Handle<v8::Value> argv[kArgc] = { obj }; 7011 v8::Handle<v8::Value> argv[kArgc] = { obj };
7010 result = v8_fun->Call(Utils::ToLocal(debug), kArgc, argv); 7012 result = v8_fun->Call(Utils::ToLocal(debug), kArgc, argv);
7011 has_pending_exception = result.IsEmpty(); 7013 has_pending_exception = result.IsEmpty();
7012 } 7014 }
7013 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); 7015 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
7014 return scope.Escape(result); 7016 return scope.Escape(result);
7015 } 7017 }
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
7691 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7693 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7692 Address callback_address = 7694 Address callback_address =
7693 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7695 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7694 VMState<EXTERNAL> state(isolate); 7696 VMState<EXTERNAL> state(isolate);
7695 ExternalCallbackScope call_scope(isolate, callback_address); 7697 ExternalCallbackScope call_scope(isolate, callback_address);
7696 callback(info); 7698 callback(info);
7697 } 7699 }
7698 7700
7699 7701
7700 } } // namespace v8::internal 7702 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698