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

Side by Side Diff: src/crankshaft/hydrogen.cc

Issue 1478303002: Revert of [runtime] Replace global object link with native context link in all contexts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
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/crankshaft/hydrogen.h" 5 #include "src/crankshaft/hydrogen.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/allocation-site-scopes.h" 9 #include "src/allocation-site-scopes.h"
10 #include "src/ast/ast-numbering.h" 10 #include "src/ast/ast-numbering.h"
(...skipping 1841 matching lines...) Expand 10 before | Expand all | Expand 10 after
1852 // the JSRegExpResult allocation. 1852 // the JSRegExpResult allocation.
1853 ElementsKind elements_kind = FAST_ELEMENTS; 1853 ElementsKind elements_kind = FAST_ELEMENTS;
1854 HValue* size = BuildCalculateElementsSize(elements_kind, length); 1854 HValue* size = BuildCalculateElementsSize(elements_kind, length);
1855 1855
1856 // Allocate the JSRegExpResult and the FixedArray in one step. 1856 // Allocate the JSRegExpResult and the FixedArray in one step.
1857 HValue* result = Add<HAllocate>( 1857 HValue* result = Add<HAllocate>(
1858 Add<HConstant>(JSRegExpResult::kSize), HType::JSArray(), 1858 Add<HConstant>(JSRegExpResult::kSize), HType::JSArray(),
1859 NOT_TENURED, JS_ARRAY_TYPE); 1859 NOT_TENURED, JS_ARRAY_TYPE);
1860 1860
1861 // Initialize the JSRegExpResult header. 1861 // Initialize the JSRegExpResult header.
1862 HValue* global_object = Add<HLoadNamedField>(
1863 context(), nullptr,
1864 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
1862 HValue* native_context = Add<HLoadNamedField>( 1865 HValue* native_context = Add<HLoadNamedField>(
1863 context(), nullptr, 1866 global_object, nullptr, HObjectAccess::ForJSGlobalObjectNativeContext());
1864 HObjectAccess::ForContextSlot(Context::NATIVE_CONTEXT_INDEX));
1865 Add<HStoreNamedField>( 1867 Add<HStoreNamedField>(
1866 result, HObjectAccess::ForMap(), 1868 result, HObjectAccess::ForMap(),
1867 Add<HLoadNamedField>( 1869 Add<HLoadNamedField>(
1868 native_context, nullptr, 1870 native_context, nullptr,
1869 HObjectAccess::ForContextSlot(Context::REGEXP_RESULT_MAP_INDEX))); 1871 HObjectAccess::ForContextSlot(Context::REGEXP_RESULT_MAP_INDEX)));
1870 HConstant* empty_fixed_array = 1872 HConstant* empty_fixed_array =
1871 Add<HConstant>(isolate()->factory()->empty_fixed_array()); 1873 Add<HConstant>(isolate()->factory()->empty_fixed_array());
1872 Add<HStoreNamedField>( 1874 Add<HStoreNamedField>(
1873 result, HObjectAccess::ForJSArrayOffset(JSArray::kPropertiesOffset), 1875 result, HObjectAccess::ForJSArrayOffset(JSArray::kPropertiesOffset),
1874 empty_fixed_array); 1876 empty_fixed_array);
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after
3251 // since the counter is bounded by the new space size. 3253 // since the counter is bounded by the new space size.
3252 memento_create_count->ClearFlag(HValue::kCanOverflow); 3254 memento_create_count->ClearFlag(HValue::kCanOverflow);
3253 Add<HStoreNamedField>( 3255 Add<HStoreNamedField>(
3254 allocation_site, HObjectAccess::ForAllocationSiteOffset( 3256 allocation_site, HObjectAccess::ForAllocationSiteOffset(
3255 AllocationSite::kPretenureCreateCountOffset), memento_create_count); 3257 AllocationSite::kPretenureCreateCountOffset), memento_create_count);
3256 } 3258 }
3257 } 3259 }
3258 3260
3259 3261
3260 HInstruction* HGraphBuilder::BuildGetNativeContext() { 3262 HInstruction* HGraphBuilder::BuildGetNativeContext() {
3261 return Add<HLoadNamedField>( 3263 // Get the global object, then the native context
3264 HValue* global_object = Add<HLoadNamedField>(
3262 context(), nullptr, 3265 context(), nullptr,
3263 HObjectAccess::ForContextSlot(Context::NATIVE_CONTEXT_INDEX)); 3266 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
3267 return Add<HLoadNamedField>(global_object, nullptr,
3268 HObjectAccess::ForObservableJSObjectOffset(
3269 JSGlobalObject::kNativeContextOffset));
3264 } 3270 }
3265 3271
3266 3272
3267 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) { 3273 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) {
3268 // Get the global object, then the native context 3274 // Get the global object, then the native context
3269 HInstruction* context = Add<HLoadNamedField>( 3275 HInstruction* context = Add<HLoadNamedField>(
3270 closure, nullptr, HObjectAccess::ForFunctionContextPointer()); 3276 closure, nullptr, HObjectAccess::ForFunctionContextPointer());
3271 return Add<HLoadNamedField>( 3277 HInstruction* global_object = Add<HLoadNamedField>(
3272 context, nullptr, 3278 context, nullptr,
3273 HObjectAccess::ForContextSlot(Context::NATIVE_CONTEXT_INDEX)); 3279 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
3280 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset(
3281 JSGlobalObject::kNativeContextOffset);
3282 return Add<HLoadNamedField>(global_object, nullptr, access);
3274 } 3283 }
3275 3284
3276 3285
3277 HInstruction* HGraphBuilder::BuildGetScriptContext(int context_index) { 3286 HInstruction* HGraphBuilder::BuildGetScriptContext(int context_index) {
3278 HValue* native_context = BuildGetNativeContext(); 3287 HValue* native_context = BuildGetNativeContext();
3279 HValue* script_context_table = Add<HLoadNamedField>( 3288 HValue* script_context_table = Add<HLoadNamedField>(
3280 native_context, nullptr, 3289 native_context, nullptr,
3281 HObjectAccess::ForContextSlot(Context::SCRIPT_CONTEXT_TABLE_INDEX)); 3290 HObjectAccess::ForContextSlot(Context::SCRIPT_CONTEXT_TABLE_INDEX));
3282 return Add<HLoadNamedField>(script_context_table, nullptr, 3291 return Add<HLoadNamedField>(script_context_table, nullptr,
3283 HObjectAccess::ForScriptContext(context_index)); 3292 HObjectAccess::ForScriptContext(context_index));
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
3534 if (fill_mode == FILL_WITH_HOLE) { 3543 if (fill_mode == FILL_WITH_HOLE) {
3535 builder()->BuildFillElementsWithHole(elements_location_, kind_, 3544 builder()->BuildFillElementsWithHole(elements_location_, kind_,
3536 graph()->GetConstant0(), capacity); 3545 graph()->GetConstant0(), capacity);
3537 } 3546 }
3538 3547
3539 return array_object; 3548 return array_object;
3540 } 3549 }
3541 3550
3542 3551
3543 HValue* HGraphBuilder::AddLoadJSBuiltin(int context_index) { 3552 HValue* HGraphBuilder::AddLoadJSBuiltin(int context_index) {
3544 HValue* native_context = BuildGetNativeContext(); 3553 HValue* global_object = Add<HLoadNamedField>(
3554 context(), nullptr,
3555 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
3556 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset(
3557 JSGlobalObject::kNativeContextOffset);
3558 HValue* native_context = Add<HLoadNamedField>(global_object, nullptr, access);
3545 HObjectAccess function_access = HObjectAccess::ForContextSlot(context_index); 3559 HObjectAccess function_access = HObjectAccess::ForContextSlot(context_index);
3546 return Add<HLoadNamedField>(native_context, nullptr, function_access); 3560 return Add<HLoadNamedField>(native_context, nullptr, function_access);
3547 } 3561 }
3548 3562
3549 3563
3550 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) 3564 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info)
3551 : HGraphBuilder(info), 3565 : HGraphBuilder(info),
3552 function_state_(NULL), 3566 function_state_(NULL),
3553 initial_function_state_(this, info, NORMAL_RETURN, 0), 3567 initial_function_state_(this, info, NORMAL_RETURN, 0),
3554 ast_context_(NULL), 3568 ast_context_(NULL),
(...skipping 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after
5693 } else { 5707 } else {
5694 instr = New<HLoadNamedField>(cell_constant, nullptr, access, 5708 instr = New<HLoadNamedField>(cell_constant, nullptr, access,
5695 field_maps, HType::HeapObject()); 5709 field_maps, HType::HeapObject());
5696 } 5710 }
5697 instr->ClearDependsOnFlag(kInobjectFields); 5711 instr->ClearDependsOnFlag(kInobjectFields);
5698 instr->SetDependsOnFlag(kGlobalVars); 5712 instr->SetDependsOnFlag(kGlobalVars);
5699 return ast_context()->ReturnInstruction(instr, expr->id()); 5713 return ast_context()->ReturnInstruction(instr, expr->id());
5700 } 5714 }
5701 } else { 5715 } else {
5702 HValue* global_object = Add<HLoadNamedField>( 5716 HValue* global_object = Add<HLoadNamedField>(
5703 BuildGetNativeContext(), nullptr, 5717 context(), nullptr,
5704 HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX)); 5718 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
5705 HLoadGlobalGeneric* instr = New<HLoadGlobalGeneric>( 5719 HLoadGlobalGeneric* instr = New<HLoadGlobalGeneric>(
5706 global_object, variable->name(), ast_context()->typeof_mode()); 5720 global_object, variable->name(), ast_context()->typeof_mode());
5707 instr->SetVectorAndSlot(handle(current_feedback_vector(), isolate()), 5721 instr->SetVectorAndSlot(handle(current_feedback_vector(), isolate()),
5708 expr->VariableFeedbackSlot()); 5722 expr->VariableFeedbackSlot());
5709 return ast_context()->ReturnInstruction(instr, expr->id()); 5723 return ast_context()->ReturnInstruction(instr, expr->id());
5710 } 5724 }
5711 } 5725 }
5712 5726
5713 case VariableLocation::PARAMETER: 5727 case VariableLocation::PARAMETER:
5714 case VariableLocation::LOCAL: { 5728 case VariableLocation::LOCAL: {
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
6907 } 6921 }
6908 } 6922 }
6909 HInstruction* instr = Add<HStoreNamedField>(cell_constant, access, value); 6923 HInstruction* instr = Add<HStoreNamedField>(cell_constant, access, value);
6910 instr->ClearChangesFlag(kInobjectFields); 6924 instr->ClearChangesFlag(kInobjectFields);
6911 instr->SetChangesFlag(kGlobalVars); 6925 instr->SetChangesFlag(kGlobalVars);
6912 if (instr->HasObservableSideEffects()) { 6926 if (instr->HasObservableSideEffects()) {
6913 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); 6927 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
6914 } 6928 }
6915 } else { 6929 } else {
6916 HValue* global_object = Add<HLoadNamedField>( 6930 HValue* global_object = Add<HLoadNamedField>(
6917 BuildGetNativeContext(), nullptr, 6931 context(), nullptr,
6918 HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX)); 6932 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
6919 HStoreNamedGeneric* instr = 6933 HStoreNamedGeneric* instr =
6920 Add<HStoreNamedGeneric>(global_object, var->name(), value, 6934 Add<HStoreNamedGeneric>(global_object, var->name(), value,
6921 function_language_mode(), PREMONOMORPHIC); 6935 function_language_mode(), PREMONOMORPHIC);
6922 Handle<TypeFeedbackVector> vector = 6936 Handle<TypeFeedbackVector> vector =
6923 handle(current_feedback_vector(), isolate()); 6937 handle(current_feedback_vector(), isolate());
6924 instr->SetVectorAndSlot(vector, slot); 6938 instr->SetVectorAndSlot(vector, slot);
6925 USE(instr); 6939 USE(instr);
6926 DCHECK(instr->HasObservableSideEffects()); 6940 DCHECK(instr->HasObservableSideEffects());
6927 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); 6941 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
6928 } 6942 }
(...skipping 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after
10010 // We HForceRepresentation here to avoid allocations during an *-to-tagged 10024 // We HForceRepresentation here to avoid allocations during an *-to-tagged
10011 // HChange that could cause GC while the array buffer object is not fully 10025 // HChange that could cause GC while the array buffer object is not fully
10012 // initialized. 10026 // initialized.
10013 HObjectAccess byte_length_access(HObjectAccess::ForJSArrayBufferByteLength()); 10027 HObjectAccess byte_length_access(HObjectAccess::ForJSArrayBufferByteLength());
10014 byte_length = AddUncasted<HForceRepresentation>( 10028 byte_length = AddUncasted<HForceRepresentation>(
10015 byte_length, byte_length_access.representation()); 10029 byte_length, byte_length_access.representation());
10016 HAllocate* result = 10030 HAllocate* result =
10017 BuildAllocate(Add<HConstant>(JSArrayBuffer::kSizeWithInternalFields), 10031 BuildAllocate(Add<HConstant>(JSArrayBuffer::kSizeWithInternalFields),
10018 HType::JSObject(), JS_ARRAY_BUFFER_TYPE, HAllocationMode()); 10032 HType::JSObject(), JS_ARRAY_BUFFER_TYPE, HAllocationMode());
10019 10033
10020 HValue* native_context = BuildGetNativeContext(); 10034 HValue* global_object = Add<HLoadNamedField>(
10035 context(), nullptr,
10036 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
10037 HValue* native_context = Add<HLoadNamedField>(
10038 global_object, nullptr, HObjectAccess::ForJSGlobalObjectNativeContext());
10021 Add<HStoreNamedField>( 10039 Add<HStoreNamedField>(
10022 result, HObjectAccess::ForMap(), 10040 result, HObjectAccess::ForMap(),
10023 Add<HLoadNamedField>( 10041 Add<HLoadNamedField>(
10024 native_context, nullptr, 10042 native_context, nullptr,
10025 HObjectAccess::ForContextSlot(Context::ARRAY_BUFFER_MAP_INDEX))); 10043 HObjectAccess::ForContextSlot(Context::ARRAY_BUFFER_MAP_INDEX)));
10026 10044
10027 HConstant* empty_fixed_array = 10045 HConstant* empty_fixed_array =
10028 Add<HConstant>(isolate()->factory()->empty_fixed_array()); 10046 Add<HConstant>(isolate()->factory()->empty_fixed_array());
10029 Add<HStoreNamedField>( 10047 Add<HStoreNamedField>(
10030 result, HObjectAccess::ForJSArrayOffset(JSArray::kPropertiesOffset), 10048 result, HObjectAccess::ForJSArrayOffset(JSArray::kPropertiesOffset),
(...skipping 3588 matching lines...) Expand 10 before | Expand all | Expand 10 after
13619 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13637 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13620 } 13638 }
13621 13639
13622 #ifdef DEBUG 13640 #ifdef DEBUG
13623 graph_->Verify(false); // No full verify. 13641 graph_->Verify(false); // No full verify.
13624 #endif 13642 #endif
13625 } 13643 }
13626 13644
13627 } // namespace internal 13645 } // namespace internal
13628 } // namespace v8 13646 } // namespace v8
OLDNEW
« no previous file with comments | « src/crankshaft/arm64/lithium-codegen-arm64.cc ('k') | src/crankshaft/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698