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

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

Issue 893993007: Protect against uninitialized lexical variables at top-level. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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/hydrogen.cc ('k') | test/cctest/test-decls.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 // 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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 718
719 if (FLAG_harmony_scoping && object->IsGlobalObject() && name->IsString()) { 719 if (FLAG_harmony_scoping && object->IsGlobalObject() && name->IsString()) {
720 // Look up in script context table. 720 // Look up in script context table.
721 Handle<String> str_name = Handle<String>::cast(name); 721 Handle<String> str_name = Handle<String>::cast(name);
722 Handle<GlobalObject> global = Handle<GlobalObject>::cast(object); 722 Handle<GlobalObject> global = Handle<GlobalObject>::cast(object);
723 Handle<ScriptContextTable> script_contexts( 723 Handle<ScriptContextTable> script_contexts(
724 global->native_context()->script_context_table()); 724 global->native_context()->script_context_table());
725 725
726 ScriptContextTable::LookupResult lookup_result; 726 ScriptContextTable::LookupResult lookup_result;
727 if (ScriptContextTable::Lookup(script_contexts, str_name, &lookup_result)) { 727 if (ScriptContextTable::Lookup(script_contexts, str_name, &lookup_result)) {
728 Handle<Object> result =
729 FixedArray::get(ScriptContextTable::GetContext(
730 script_contexts, lookup_result.context_index),
731 lookup_result.slot_index);
732 if (*result == *isolate()->factory()->the_hole_value()) {
733 // Do not install stubs and stay pre-monomorphic for
734 // uninitialized accesses.
735 return ReferenceError("not_defined", name);
736 }
737
728 if (use_ic && LoadScriptContextFieldStub::Accepted(&lookup_result)) { 738 if (use_ic && LoadScriptContextFieldStub::Accepted(&lookup_result)) {
729 LoadScriptContextFieldStub stub(isolate(), &lookup_result); 739 LoadScriptContextFieldStub stub(isolate(), &lookup_result);
730 PatchCache(name, stub.GetCode()); 740 PatchCache(name, stub.GetCode());
731 } 741 }
732 return FixedArray::get(ScriptContextTable::GetContext( 742 return result;
733 script_contexts, lookup_result.context_index),
734 lookup_result.slot_index);
735 } 743 }
736 } 744 }
737 745
738 // Named lookup in the object. 746 // Named lookup in the object.
739 LookupIterator it(object, name); 747 LookupIterator it(object, name);
740 LookupForRead(&it); 748 LookupForRead(&it);
741 749
742 if (it.IsFound() || !IsUndeclaredGlobal(object)) { 750 if (it.IsFound() || !IsUndeclaredGlobal(object)) {
743 // Update inline cache and stub cache. 751 // Update inline cache and stub cache.
744 if (use_ic) UpdateCaches(&it); 752 if (use_ic) UpdateCaches(&it);
(...skipping 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after
2989 static const Address IC_utilities[] = { 2997 static const Address IC_utilities[] = {
2990 #define ADDR(name) FUNCTION_ADDR(name), 2998 #define ADDR(name) FUNCTION_ADDR(name),
2991 IC_UTIL_LIST(ADDR) NULL 2999 IC_UTIL_LIST(ADDR) NULL
2992 #undef ADDR 3000 #undef ADDR
2993 }; 3001 };
2994 3002
2995 3003
2996 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } 3004 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; }
2997 } 3005 }
2998 } // namespace v8::internal 3006 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | test/cctest/test-decls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698