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

Side by Side Diff: src/api.cc

Issue 225283005: Return MaybeHandle from SetProperty. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments 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 | « src/accessors.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
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 3031 matching lines...) Expand 10 before | Expand all | Expand 10 after
3042 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value, 3042 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value,
3043 v8::PropertyAttribute attribs) { 3043 v8::PropertyAttribute attribs) {
3044 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3044 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3045 ON_BAILOUT(isolate, "v8::Object::Set()", return false); 3045 ON_BAILOUT(isolate, "v8::Object::Set()", return false);
3046 ENTER_V8(isolate); 3046 ENTER_V8(isolate);
3047 i::HandleScope scope(isolate); 3047 i::HandleScope scope(isolate);
3048 i::Handle<i::Object> self = Utils::OpenHandle(this); 3048 i::Handle<i::Object> self = Utils::OpenHandle(this);
3049 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3049 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3050 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3050 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3051 EXCEPTION_PREAMBLE(isolate); 3051 EXCEPTION_PREAMBLE(isolate);
3052 i::Handle<i::Object> obj = i::Runtime::SetObjectProperty( 3052 has_pending_exception = i::Runtime::SetObjectProperty(
3053 isolate, 3053 isolate,
3054 self, 3054 self,
3055 key_obj, 3055 key_obj,
3056 value_obj, 3056 value_obj,
3057 static_cast<PropertyAttributes>(attribs), 3057 static_cast<PropertyAttributes>(attribs),
3058 i::SLOPPY); 3058 i::SLOPPY).is_null();
3059 has_pending_exception = obj.is_null();
3060 EXCEPTION_BAILOUT_CHECK(isolate, false); 3059 EXCEPTION_BAILOUT_CHECK(isolate, false);
3061 return true; 3060 return true;
3062 } 3061 }
3063 3062
3064 3063
3065 bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) { 3064 bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) {
3066 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3065 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3067 ON_BAILOUT(isolate, "v8::Object::Set()", return false); 3066 ON_BAILOUT(isolate, "v8::Object::Set()", return false);
3068 ENTER_V8(isolate); 3067 ENTER_V8(isolate);
3069 i::HandleScope scope(isolate); 3068 i::HandleScope scope(isolate);
(...skipping 16 matching lines...) Expand all
3086 v8::Handle<Value> value, 3085 v8::Handle<Value> value,
3087 v8::PropertyAttribute attribs) { 3086 v8::PropertyAttribute attribs) {
3088 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3087 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3089 ON_BAILOUT(isolate, "v8::Object::ForceSet()", return false); 3088 ON_BAILOUT(isolate, "v8::Object::ForceSet()", return false);
3090 ENTER_V8(isolate); 3089 ENTER_V8(isolate);
3091 i::HandleScope scope(isolate); 3090 i::HandleScope scope(isolate);
3092 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3091 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3093 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3092 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3094 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3093 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3095 EXCEPTION_PREAMBLE(isolate); 3094 EXCEPTION_PREAMBLE(isolate);
3096 i::Handle<i::Object> obj = i::ForceSetProperty( 3095 has_pending_exception = i::Runtime::ForceSetObjectProperty(
3097 self, 3096 self,
3098 key_obj, 3097 key_obj,
3099 value_obj, 3098 value_obj,
3100 static_cast<PropertyAttributes>(attribs)); 3099 static_cast<PropertyAttributes>(attribs)).is_null();
3101 has_pending_exception = obj.is_null();
3102 EXCEPTION_BAILOUT_CHECK(isolate, false); 3100 EXCEPTION_BAILOUT_CHECK(isolate, false);
3103 return true; 3101 return true;
3104 } 3102 }
3105 3103
3106 3104
3107 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) { 3105 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) {
3108 return Set(v8::Handle<Value>(reinterpret_cast<Value*>(*key)), 3106 return Set(v8::Handle<Value>(reinterpret_cast<Value*>(*key)),
3109 value, DontEnum); 3107 value, DontEnum);
3110 } 3108 }
3111 3109
(...skipping 3038 matching lines...) Expand 10 before | Expand all | Expand 10 after
6150 i::Handle<i::String> part = i_isolate->factory()->for_string(); 6148 i::Handle<i::String> part = i_isolate->factory()->for_string();
6151 i::Handle<i::JSObject> symbols = 6149 i::Handle<i::JSObject> symbols =
6152 i::Handle<i::JSObject>::cast( 6150 i::Handle<i::JSObject>::cast(
6153 i::Object::GetPropertyOrElement(registry, part)); 6151 i::Object::GetPropertyOrElement(registry, part));
6154 i::Handle<i::Object> symbol = 6152 i::Handle<i::Object> symbol =
6155 i::Object::GetPropertyOrElement(symbols, i_name); 6153 i::Object::GetPropertyOrElement(symbols, i_name);
6156 if (!symbol->IsSymbol()) { 6154 if (!symbol->IsSymbol()) {
6157 ASSERT(symbol->IsUndefined()); 6155 ASSERT(symbol->IsUndefined());
6158 symbol = i_isolate->factory()->NewSymbol(); 6156 symbol = i_isolate->factory()->NewSymbol();
6159 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); 6157 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6160 i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT); 6158 i::JSObject::SetProperty(
6159 symbols, i_name, symbol, NONE, i::STRICT).Assert();
6161 } 6160 }
6162 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); 6161 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol));
6163 } 6162 }
6164 6163
6165 6164
6166 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) { 6165 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) {
6167 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6166 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6168 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 6167 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
6169 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); 6168 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry();
6170 i::Handle<i::String> part = i_isolate->factory()->for_api_string(); 6169 i::Handle<i::String> part = i_isolate->factory()->for_api_string();
6171 i::Handle<i::JSObject> symbols = 6170 i::Handle<i::JSObject> symbols =
6172 i::Handle<i::JSObject>::cast( 6171 i::Handle<i::JSObject>::cast(
6173 i::Object::GetPropertyOrElement(registry, part)); 6172 i::Object::GetPropertyOrElement(registry, part));
6174 i::Handle<i::Object> symbol = 6173 i::Handle<i::Object> symbol =
6175 i::Object::GetPropertyOrElement(symbols, i_name); 6174 i::Object::GetPropertyOrElement(symbols, i_name);
6176 if (!symbol->IsSymbol()) { 6175 if (!symbol->IsSymbol()) {
6177 ASSERT(symbol->IsUndefined()); 6176 ASSERT(symbol->IsUndefined());
6178 symbol = i_isolate->factory()->NewSymbol(); 6177 symbol = i_isolate->factory()->NewSymbol();
6179 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); 6178 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6180 i::JSObject::SetProperty(symbols, i_name, symbol, NONE, i::STRICT); 6179 i::JSObject::SetProperty(
6180 symbols, i_name, symbol, NONE, i::STRICT).Assert();
6181 } 6181 }
6182 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); 6182 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol));
6183 } 6183 }
6184 6184
6185 6185
6186 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { 6186 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
6187 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6187 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6188 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); 6188 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()");
6189 LOG_API(i_isolate, "Private::New()"); 6189 LOG_API(i_isolate, "Private::New()");
6190 ENTER_V8(i_isolate); 6190 ENTER_V8(i_isolate);
(...skipping 11 matching lines...) Expand all
6202 i::Handle<i::String> part = i_isolate->factory()->private_api_string(); 6202 i::Handle<i::String> part = i_isolate->factory()->private_api_string();
6203 i::Handle<i::JSObject> privates = 6203 i::Handle<i::JSObject> privates =
6204 i::Handle<i::JSObject>::cast( 6204 i::Handle<i::JSObject>::cast(
6205 i::Object::GetPropertyOrElement(registry, part)); 6205 i::Object::GetPropertyOrElement(registry, part));
6206 i::Handle<i::Object> symbol = 6206 i::Handle<i::Object> symbol =
6207 i::Object::GetPropertyOrElement(privates, i_name); 6207 i::Object::GetPropertyOrElement(privates, i_name);
6208 if (!symbol->IsSymbol()) { 6208 if (!symbol->IsSymbol()) {
6209 ASSERT(symbol->IsUndefined()); 6209 ASSERT(symbol->IsUndefined());
6210 symbol = i_isolate->factory()->NewPrivateSymbol(); 6210 symbol = i_isolate->factory()->NewPrivateSymbol();
6211 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); 6211 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6212 i::JSObject::SetProperty(privates, i_name, symbol, NONE, i::STRICT); 6212 i::JSObject::SetProperty(
6213 privates, i_name, symbol, NONE, i::STRICT).Assert();
6213 } 6214 }
6214 Local<Symbol> result = Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); 6215 Local<Symbol> result = Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol));
6215 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); 6216 return v8::Handle<Private>(reinterpret_cast<Private*>(*result));
6216 } 6217 }
6217 6218
6218 6219
6219 Local<Number> v8::Number::New(Isolate* isolate, double value) { 6220 Local<Number> v8::Number::New(Isolate* isolate, double value) {
6220 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 6221 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6221 ASSERT(internal_isolate->IsInitialized()); 6222 ASSERT(internal_isolate->IsInitialized());
6222 if (std::isnan(value)) { 6223 if (std::isnan(value)) {
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
6957 } 6958 }
6958 6959
6959 6960
6960 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) { 6961 Local<Value> Debug::GetMirror(v8::Handle<v8::Value> obj) {
6961 i::Isolate* isolate = i::Isolate::Current(); 6962 i::Isolate* isolate = i::Isolate::Current();
6962 if (!isolate->IsInitialized()) return Local<Value>(); 6963 if (!isolate->IsInitialized()) return Local<Value>();
6963 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>()); 6964 ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>());
6964 ENTER_V8(isolate); 6965 ENTER_V8(isolate);
6965 v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); 6966 v8::EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate));
6966 i::Debug* isolate_debug = isolate->debug(); 6967 i::Debug* isolate_debug = isolate->debug();
6967 isolate_debug->Load();
6968 i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object());
6969 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString(
6970 STATIC_ASCII_VECTOR("MakeMirror"));
6971 i::Handle<i::Object> fun_obj = i::Object::GetProperty(debug, name);
6972 ASSERT(!fun_obj.is_null());
6973 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj);
6974 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun);
6975 const int kArgc = 1;
6976 v8::Handle<v8::Value> argv[kArgc] = { obj };
6977 EXCEPTION_PREAMBLE(isolate); 6968 EXCEPTION_PREAMBLE(isolate);
6978 v8::Local<v8::Value> result = 6969 has_pending_exception = !isolate_debug->Load();
6979 v8_fun->Call(Utils::ToLocal(debug), kArgc, argv); 6970 v8::Local<v8::Value> result;
6971 if (!has_pending_exception) {
6972 i::Handle<i::JSObject> debug(
6973 isolate_debug->debug_context()->global_object());
6974 i::Handle<i::String> name = isolate->factory()->InternalizeOneByteString(
6975 STATIC_ASCII_VECTOR("MakeMirror"));
6976 i::Handle<i::Object> fun_obj = i::Object::GetProperty(debug, name);
6977 ASSERT(!fun_obj.is_null());
6978 i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(fun_obj);
6979 v8::Handle<v8::Function> v8_fun = Utils::ToLocal(fun);
6980 const int kArgc = 1;
6981 v8::Handle<v8::Value> argv[kArgc] = { obj };
6982 result = v8_fun->Call(Utils::ToLocal(debug), kArgc, argv);
6983 has_pending_exception = result.IsEmpty();
6984 }
6980 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); 6985 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
6981 return scope.Escape(result); 6986 return scope.Escape(result);
6982 } 6987 }
6983 6988
6984 6989
6985 bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) { 6990 bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) {
6986 return i::Isolate::Current()->debugger()->StartAgent(name, port, 6991 return i::Isolate::Current()->debugger()->StartAgent(name, port,
6987 wait_for_connection); 6992 wait_for_connection);
6988 } 6993 }
6989 6994
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
7658 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7663 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7659 Address callback_address = 7664 Address callback_address =
7660 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7665 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7661 VMState<EXTERNAL> state(isolate); 7666 VMState<EXTERNAL> state(isolate);
7662 ExternalCallbackScope call_scope(isolate, callback_address); 7667 ExternalCallbackScope call_scope(isolate, callback_address);
7663 callback(info); 7668 callback(info);
7664 } 7669 }
7665 7670
7666 7671
7667 } } // namespace v8::internal 7672 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698