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

Side by Side Diff: src/objects.cc

Issue 331313010: Simplify Object::GetElementWithReceiver (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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 | 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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 Handle<Object> receiver, 806 Handle<Object> receiver,
807 uint32_t index) { 807 uint32_t index) {
808 Handle<Object> holder; 808 Handle<Object> holder;
809 809
810 // Iterate up the prototype chain until an element is found or the null 810 // Iterate up the prototype chain until an element is found or the null
811 // prototype is encountered. 811 // prototype is encountered.
812 for (holder = object; 812 for (holder = object;
813 !holder->IsNull(); 813 !holder->IsNull();
814 holder = Handle<Object>(holder->GetPrototype(isolate), isolate)) { 814 holder = Handle<Object>(holder->GetPrototype(isolate), isolate)) {
815 if (!holder->IsJSObject()) { 815 if (!holder->IsJSObject()) {
816 Context* native_context = isolate->context()->native_context(); 816 if (holder->IsJSProxy()) {
817 if (holder->IsNumber()) {
818 holder = Handle<Object>(
819 native_context->number_function()->instance_prototype(), isolate);
820 } else if (holder->IsString()) {
821 holder = Handle<Object>(
822 native_context->string_function()->instance_prototype(), isolate);
823 } else if (holder->IsSymbol()) {
824 holder = Handle<Object>(
825 native_context->symbol_function()->instance_prototype(), isolate);
826 } else if (holder->IsBoolean()) {
827 holder = Handle<Object>(
828 native_context->boolean_function()->instance_prototype(), isolate);
829 } else if (holder->IsJSProxy()) {
830 return JSProxy::GetElementWithHandler( 817 return JSProxy::GetElementWithHandler(
831 Handle<JSProxy>::cast(holder), receiver, index); 818 Handle<JSProxy>::cast(holder), receiver, index);
819 } else if (holder->IsUndefined()) {
820 // Undefined has no indexed properties.
821 return isolate->factory()->undefined_value();
832 } else { 822 } else {
833 // Undefined and null have no indexed properties. 823 holder = Handle<Object>(holder->GetPrototype(isolate), isolate);
834 ASSERT(holder->IsUndefined() || holder->IsNull()); 824 ASSERT(holder->IsJSObject());
835 return isolate->factory()->undefined_value();
836 } 825 }
837 } 826 }
838 827
839 // Inline the case for JSObjects. Doing so significantly improves the 828 // Inline the case for JSObjects. Doing so significantly improves the
840 // performance of fetching elements where checking the prototype chain is 829 // performance of fetching elements where checking the prototype chain is
841 // necessary. 830 // necessary.
842 Handle<JSObject> js_object = Handle<JSObject>::cast(holder); 831 Handle<JSObject> js_object = Handle<JSObject>::cast(holder);
843 832
844 // Check access rights if needed. 833 // Check access rights if needed.
845 if (js_object->IsAccessCheckNeeded()) { 834 if (js_object->IsAccessCheckNeeded()) {
(...skipping 16154 matching lines...) Expand 10 before | Expand all | Expand 10 after
17000 #define ERROR_MESSAGES_TEXTS(C, T) T, 16989 #define ERROR_MESSAGES_TEXTS(C, T) T,
17001 static const char* error_messages_[] = { 16990 static const char* error_messages_[] = {
17002 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16991 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
17003 }; 16992 };
17004 #undef ERROR_MESSAGES_TEXTS 16993 #undef ERROR_MESSAGES_TEXTS
17005 return error_messages_[reason]; 16994 return error_messages_[reason];
17006 } 16995 }
17007 16996
17008 16997
17009 } } // namespace v8::internal 16998 } } // 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