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

Side by Side Diff: src/ic/ic.cc

Issue 1227893005: TypeofMode replaces TypeofState and ContextualMode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 5 years, 5 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
« no previous file with comments | « src/ic/ic.h ('k') | src/ic/ic-inl.h » ('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 // 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/api.h" 8 #include "src/api.h"
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 PatchCache(name, stub.GetCode()); 727 PatchCache(name, stub.GetCode());
728 } 728 }
729 return result; 729 return result;
730 } 730 }
731 } 731 }
732 732
733 // Named lookup in the object. 733 // Named lookup in the object.
734 LookupIterator it(object, name); 734 LookupIterator it(object, name);
735 LookupForRead(&it); 735 LookupForRead(&it);
736 736
737 if (it.IsFound() || !IsUndeclaredGlobal(object)) { 737 if (it.IsFound() || !ShouldThrowReferenceError(object)) {
738 // Update inline cache and stub cache. 738 // Update inline cache and stub cache.
739 if (use_ic) UpdateCaches(&it); 739 if (use_ic) UpdateCaches(&it);
740 740
741 // Get the property. 741 // Get the property.
742 Handle<Object> result; 742 Handle<Object> result;
743 743
744 ASSIGN_RETURN_ON_EXCEPTION( 744 ASSIGN_RETURN_ON_EXCEPTION(
745 isolate(), result, Object::GetProperty(&it, language_mode()), Object); 745 isolate(), result, Object::GetProperty(&it, language_mode()), Object);
746 if (it.IsFound()) { 746 if (it.IsFound()) {
747 return result; 747 return result;
748 } else if (!IsUndeclaredGlobal(object)) { 748 } else if (!ShouldThrowReferenceError(object)) {
749 LOG(isolate(), SuspectReadEvent(*name, *object)); 749 LOG(isolate(), SuspectReadEvent(*name, *object));
750 return result; 750 return result;
751 } 751 }
752 } 752 }
753 return ReferenceError(name); 753 return ReferenceError(name);
754 } 754 }
755 755
756 756
757 static bool AddOneReceiverMapIfMissing(MapHandleList* receiver_maps, 757 static bool AddOneReceiverMapIfMissing(MapHandleList* receiver_maps,
758 Handle<Map> new_receiver_map) { 758 Handle<Map> new_receiver_map) {
(...skipping 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after
2977 LookupIterator it(receiver, name, holder, LookupIterator::OWN); 2977 LookupIterator it(receiver, name, holder, LookupIterator::OWN);
2978 bool done; 2978 bool done;
2979 Handle<Object> result; 2979 Handle<Object> result;
2980 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 2980 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
2981 isolate, result, JSObject::GetPropertyWithInterceptor(&it, &done)); 2981 isolate, result, JSObject::GetPropertyWithInterceptor(&it, &done));
2982 if (done) return *result; 2982 if (done) return *result;
2983 return isolate->heap()->no_interceptor_result_sentinel(); 2983 return isolate->heap()->no_interceptor_result_sentinel();
2984 } 2984 }
2985 2985
2986 2986
2987 static Object* ThrowReferenceError(Isolate* isolate, Name* name) {
2988 // If the load is non-contextual, just return the undefined result.
2989 // Note that both keyed and non-keyed loads may end up here.
2990 HandleScope scope(isolate);
2991 LoadIC ic(IC::NO_EXTRA_FRAME, isolate, true);
2992 if (ic.contextual_mode() != CONTEXTUAL) {
2993 return isolate->heap()->undefined_value();
2994 }
2995
2996 // Throw a reference error.
2997 Handle<Name> name_handle(name);
2998 THROW_NEW_ERROR_RETURN_FAILURE(
2999 isolate, NewReferenceError(MessageTemplate::kNotDefined, name_handle));
3000 }
3001
3002
3003 /** 2987 /**
3004 * Loads a property with an interceptor performing post interceptor 2988 * Loads a property with an interceptor performing post interceptor
3005 * lookup if interceptor failed. 2989 * lookup if interceptor failed.
3006 */ 2990 */
3007 RUNTIME_FUNCTION(LoadPropertyWithInterceptor) { 2991 RUNTIME_FUNCTION(LoadPropertyWithInterceptor) {
3008 HandleScope scope(isolate); 2992 HandleScope scope(isolate);
3009 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); 2993 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength);
3010 Handle<Name> name = 2994 Handle<Name> name =
3011 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex); 2995 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex);
3012 Handle<JSObject> receiver = 2996 Handle<JSObject> receiver =
3013 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex); 2997 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex);
3014 Handle<JSObject> holder = 2998 Handle<JSObject> holder =
3015 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex); 2999 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex);
3016 3000
3017 Handle<Object> result; 3001 Handle<Object> result;
3018 LookupIterator it(receiver, name, holder); 3002 LookupIterator it(receiver, name, holder);
3019 // TODO(conradw): Investigate strong mode semantics for this. 3003 // TODO(conradw): Investigate strong mode semantics for this.
3020 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, 3004 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
3021 JSObject::GetProperty(&it)); 3005 JSObject::GetProperty(&it));
3022 3006
3023 if (it.IsFound()) return *result; 3007 if (it.IsFound()) return *result;
3024 3008
3025 return ThrowReferenceError(isolate, Name::cast(args[0])); 3009 // Return the undefined result if the reference error should not be thrown.
3010 // Note that both keyed and non-keyed loads may end up here.
3011 LoadIC ic(IC::NO_EXTRA_FRAME, isolate, true);
3012 if (!ic.ShouldThrowReferenceError(it.GetReceiver())) {
3013 return isolate->heap()->undefined_value();
3014 }
3015
3016 // Throw a reference error.
3017 THROW_NEW_ERROR_RETURN_FAILURE(
3018 isolate, NewReferenceError(MessageTemplate::kNotDefined, it.name()));
3026 } 3019 }
3027 3020
3028 3021
3029 RUNTIME_FUNCTION(StorePropertyWithInterceptor) { 3022 RUNTIME_FUNCTION(StorePropertyWithInterceptor) {
3030 HandleScope scope(isolate); 3023 HandleScope scope(isolate);
3031 DCHECK(args.length() == 3); 3024 DCHECK(args.length() == 3);
3032 StoreIC ic(IC::NO_EXTRA_FRAME, isolate); 3025 StoreIC ic(IC::NO_EXTRA_FRAME, isolate);
3033 Handle<JSObject> receiver = args.at<JSObject>(0); 3026 Handle<JSObject> receiver = args.at<JSObject>(0);
3034 Handle<Name> name = args.at<Name>(1); 3027 Handle<Name> name = args.at<Name>(1);
3035 Handle<Object> value = args.at<Object>(2); 3028 Handle<Object> value = args.at<Object>(2);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
3105 static const Address IC_utilities[] = { 3098 static const Address IC_utilities[] = {
3106 #define ADDR(name) FUNCTION_ADDR(name), 3099 #define ADDR(name) FUNCTION_ADDR(name),
3107 IC_UTIL_LIST(ADDR) NULL 3100 IC_UTIL_LIST(ADDR) NULL
3108 #undef ADDR 3101 #undef ADDR
3109 }; 3102 };
3110 3103
3111 3104
3112 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } 3105 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; }
3113 } // namespace internal 3106 } // namespace internal
3114 } // namespace v8 3107 } // namespace v8
OLDNEW
« no previous file with comments | « src/ic/ic.h ('k') | src/ic/ic-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698