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

Side by Side Diff: src/runtime/runtime-object.cc

Issue 803833004: Add fast path for array indices to Runtime_HasOwnProperty (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/v8.h" 5 #include "src/v8.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.h" 9 #include "src/debug.h"
10 #include "src/runtime/runtime.h" 10 #include "src/runtime/runtime.h"
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 808
809 uint32_t index; 809 uint32_t index;
810 const bool key_is_array_index = key->AsArrayIndex(&index); 810 const bool key_is_array_index = key->AsArrayIndex(&index);
811 811
812 // Only JS objects can have properties. 812 // Only JS objects can have properties.
813 if (object->IsJSObject()) { 813 if (object->IsJSObject()) {
814 Handle<JSObject> js_obj = Handle<JSObject>::cast(object); 814 Handle<JSObject> js_obj = Handle<JSObject>::cast(object);
815 // Fast case: either the key is a real named property or it is not 815 // Fast case: either the key is a real named property or it is not
816 // an array index and there are no interceptors or hidden 816 // an array index and there are no interceptors or hidden
817 // prototypes. 817 // prototypes.
818 Maybe<bool> maybe = JSObject::HasRealNamedProperty(js_obj, key); 818 Maybe<bool> maybe;
819 if (key_is_array_index) {
820 maybe = JSObject::HasOwnElement(js_obj, index);
821 } else {
822 maybe = JSObject::HasRealNamedProperty(js_obj, key);
823 }
819 if (!maybe.has_value) return isolate->heap()->exception(); 824 if (!maybe.has_value) return isolate->heap()->exception();
820 DCHECK(!isolate->has_pending_exception()); 825 DCHECK(!isolate->has_pending_exception());
821 if (maybe.value) { 826 if (maybe.value) {
822 return isolate->heap()->true_value(); 827 return isolate->heap()->true_value();
823 } 828 }
824 Map* map = js_obj->map(); 829 Map* map = js_obj->map();
825 if (!key_is_array_index && !map->has_named_interceptor() && 830 if (!key_is_array_index && !map->has_named_interceptor() &&
826 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) { 831 !HeapObject::cast(map->prototype())->map()->is_hidden_prototype()) {
827 return isolate->heap()->false_value(); 832 return isolate->heap()->false_value();
828 } 833 }
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 1605
1601 RUNTIME_FUNCTION(RuntimeReference_ClassOf) { 1606 RUNTIME_FUNCTION(RuntimeReference_ClassOf) {
1602 SealHandleScope shs(isolate); 1607 SealHandleScope shs(isolate);
1603 DCHECK(args.length() == 1); 1608 DCHECK(args.length() == 1);
1604 CONVERT_ARG_CHECKED(Object, obj, 0); 1609 CONVERT_ARG_CHECKED(Object, obj, 0);
1605 if (!obj->IsJSReceiver()) return isolate->heap()->null_value(); 1610 if (!obj->IsJSReceiver()) return isolate->heap()->null_value();
1606 return JSReceiver::cast(obj)->class_name(); 1611 return JSReceiver::cast(obj)->class_name();
1607 } 1612 }
1608 } 1613 }
1609 } // namespace v8::internal 1614 } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698