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

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

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