OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 return Runtime::GetObjectProperty(isolate, receiver_obj, key_obj); | 113 return Runtime::GetObjectProperty(isolate, receiver_obj, key_obj); |
114 } | 114 } |
115 | 115 |
116 | 116 |
117 Maybe<bool> Runtime::DeleteObjectProperty(Isolate* isolate, | 117 Maybe<bool> Runtime::DeleteObjectProperty(Isolate* isolate, |
118 Handle<JSReceiver> receiver, | 118 Handle<JSReceiver> receiver, |
119 Handle<Object> key, | 119 Handle<Object> key, |
120 LanguageMode language_mode) { | 120 LanguageMode language_mode) { |
121 bool success = false; | 121 bool success = false; |
122 LookupIterator it = LookupIterator::PropertyOrElement( | 122 LookupIterator it = LookupIterator::PropertyOrElement( |
123 isolate, receiver, key, &success, LookupIterator::HIDDEN); | 123 isolate, receiver, key, &success, LookupIterator::OWN); |
124 if (!success) return Nothing<bool>(); | 124 if (!success) return Nothing<bool>(); |
125 | 125 |
126 return JSReceiver::DeleteProperty(&it, language_mode); | 126 return JSReceiver::DeleteProperty(&it, language_mode); |
127 } | 127 } |
128 | 128 |
129 // ES6 19.1.3.2 | 129 // ES6 19.1.3.2 |
130 RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) { | 130 RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) { |
131 HandleScope scope(isolate); | 131 HandleScope scope(isolate); |
132 Handle<Object> property = args.at<Object>(1); | 132 Handle<Object> property = args.at<Object>(1); |
133 | 133 |
(...skipping 28 matching lines...) Expand all Loading... |
162 } | 162 } |
163 | 163 |
164 Map* map = js_obj->map(); | 164 Map* map = js_obj->map(); |
165 if (!map->has_hidden_prototype() && | 165 if (!map->has_hidden_prototype() && |
166 (key_is_array_index ? !map->has_indexed_interceptor() | 166 (key_is_array_index ? !map->has_indexed_interceptor() |
167 : !map->has_named_interceptor())) { | 167 : !map->has_named_interceptor())) { |
168 return isolate->heap()->false_value(); | 168 return isolate->heap()->false_value(); |
169 } | 169 } |
170 | 170 |
171 // Slow case. | 171 // Slow case. |
172 LookupIterator::Configuration c = LookupIterator::HIDDEN; | 172 LookupIterator::Configuration c = LookupIterator::OWN; |
173 LookupIterator it = key_is_array_index | 173 LookupIterator it = key_is_array_index |
174 ? LookupIterator(isolate, js_obj, index, js_obj, c) | 174 ? LookupIterator(isolate, js_obj, index, js_obj, c) |
175 : LookupIterator(js_obj, key, js_obj, c); | 175 : LookupIterator(js_obj, key, js_obj, c); |
176 | 176 |
177 Maybe<bool> maybe = JSReceiver::HasProperty(&it); | 177 Maybe<bool> maybe = JSReceiver::HasProperty(&it); |
178 if (maybe.IsNothing()) return isolate->heap()->exception(); | 178 if (maybe.IsNothing()) return isolate->heap()->exception(); |
179 DCHECK(!isolate->has_pending_exception()); | 179 DCHECK(!isolate->has_pending_exception()); |
180 return isolate->heap()->ToBoolean(maybe.FromJust()); | 180 return isolate->heap()->ToBoolean(maybe.FromJust()); |
181 | 181 |
182 } else if (object->IsJSProxy()) { | 182 } else if (object->IsJSProxy()) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 // Go up context chain to the script context. | 293 // Go up context chain to the script context. |
294 Handle<Context> script_context(isolate->context()->script_context(), isolate); | 294 Handle<Context> script_context(isolate->context()->script_context(), isolate); |
295 DCHECK(script_context->IsScriptContext()); | 295 DCHECK(script_context->IsScriptContext()); |
296 DCHECK(script_context->get(slot)->IsPropertyCell()); | 296 DCHECK(script_context->get(slot)->IsPropertyCell()); |
297 | 297 |
298 // Lookup the named property on the global object. | 298 // Lookup the named property on the global object. |
299 Handle<ScopeInfo> scope_info(script_context->scope_info(), isolate); | 299 Handle<ScopeInfo> scope_info(script_context->scope_info(), isolate); |
300 Handle<Name> name(scope_info->ContextSlotName(slot), isolate); | 300 Handle<Name> name(scope_info->ContextSlotName(slot), isolate); |
301 Handle<JSGlobalObject> global_object(script_context->global_object(), | 301 Handle<JSGlobalObject> global_object(script_context->global_object(), |
302 isolate); | 302 isolate); |
303 LookupIterator it(global_object, name, global_object, LookupIterator::HIDDEN); | 303 LookupIterator it(global_object, name, global_object, LookupIterator::OWN); |
304 | 304 |
305 // Switch to fast mode only if there is a data property and it's not on | 305 // Switch to fast mode only if there is a data property and it's not on |
306 // a hidden prototype. | 306 // a hidden prototype. |
307 if (it.state() == LookupIterator::DATA && | 307 if (it.state() == LookupIterator::DATA && |
308 it.GetHolder<Object>().is_identical_to(global_object)) { | 308 it.GetHolder<Object>().is_identical_to(global_object)) { |
309 // Now update the cell in the script context. | 309 // Now update the cell in the script context. |
310 Handle<PropertyCell> cell = it.GetPropertyCell(); | 310 Handle<PropertyCell> cell = it.GetPropertyCell(); |
311 script_context->set(slot, *cell); | 311 script_context->set(slot, *cell); |
312 } else { | 312 } else { |
313 // This is not a fast case, so keep this access in a slow mode. | 313 // This is not a fast case, so keep this access in a slow mode. |
(...skipping 14 matching lines...) Expand all Loading... |
328 // Go up context chain to the script context. | 328 // Go up context chain to the script context. |
329 Handle<Context> script_context(isolate->context()->script_context(), isolate); | 329 Handle<Context> script_context(isolate->context()->script_context(), isolate); |
330 DCHECK(script_context->IsScriptContext()); | 330 DCHECK(script_context->IsScriptContext()); |
331 DCHECK(script_context->get(slot)->IsPropertyCell()); | 331 DCHECK(script_context->get(slot)->IsPropertyCell()); |
332 | 332 |
333 // Lookup the named property on the global object. | 333 // Lookup the named property on the global object. |
334 Handle<ScopeInfo> scope_info(script_context->scope_info(), isolate); | 334 Handle<ScopeInfo> scope_info(script_context->scope_info(), isolate); |
335 Handle<Name> name(scope_info->ContextSlotName(slot), isolate); | 335 Handle<Name> name(scope_info->ContextSlotName(slot), isolate); |
336 Handle<JSGlobalObject> global_object(script_context->global_object(), | 336 Handle<JSGlobalObject> global_object(script_context->global_object(), |
337 isolate); | 337 isolate); |
338 LookupIterator it(global_object, name, global_object, LookupIterator::HIDDEN); | 338 LookupIterator it(global_object, name, global_object, LookupIterator::OWN); |
339 | 339 |
340 // Switch to fast mode only if there is a data property and it's not on | 340 // Switch to fast mode only if there is a data property and it's not on |
341 // a hidden prototype. | 341 // a hidden prototype. |
342 if (it.state() == LookupIterator::DATA && | 342 if (it.state() == LookupIterator::DATA && |
343 it.GetHolder<Object>().is_identical_to(global_object)) { | 343 it.GetHolder<Object>().is_identical_to(global_object)) { |
344 // Now update cell in the script context. | 344 // Now update cell in the script context. |
345 Handle<PropertyCell> cell = it.GetPropertyCell(); | 345 Handle<PropertyCell> cell = it.GetPropertyCell(); |
346 script_context->set(slot, *cell); | 346 script_context->set(slot, *cell); |
347 } else { | 347 } else { |
348 // This is not a fast case, so keep this access in a slow mode. | 348 // This is not a fast case, so keep this access in a slow mode. |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 | 1109 |
1110 | 1110 |
1111 RUNTIME_FUNCTION(Runtime_CreateDataProperty) { | 1111 RUNTIME_FUNCTION(Runtime_CreateDataProperty) { |
1112 HandleScope scope(isolate); | 1112 HandleScope scope(isolate); |
1113 DCHECK(args.length() == 3); | 1113 DCHECK(args.length() == 3); |
1114 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, o, 0); | 1114 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, o, 0); |
1115 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1115 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1116 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 1116 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
1117 bool success; | 1117 bool success; |
1118 LookupIterator it = LookupIterator::PropertyOrElement( | 1118 LookupIterator it = LookupIterator::PropertyOrElement( |
1119 isolate, o, key, &success, LookupIterator::HIDDEN); | 1119 isolate, o, key, &success, LookupIterator::OWN); |
1120 if (!success) return isolate->heap()->exception(); | 1120 if (!success) return isolate->heap()->exception(); |
1121 MAYBE_RETURN( | 1121 MAYBE_RETURN( |
1122 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), | 1122 JSReceiver::CreateDataProperty(&it, value, Object::THROW_ON_ERROR), |
1123 isolate->heap()->exception()); | 1123 isolate->heap()->exception()); |
1124 return *value; | 1124 return *value; |
1125 } | 1125 } |
1126 | 1126 |
1127 } // namespace internal | 1127 } // namespace internal |
1128 } // namespace v8 | 1128 } // namespace v8 |
OLD | NEW |