| OLD | NEW |
| 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-numbering.h" | 10 #include "src/ast-numbering.h" |
| (...skipping 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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* global_object = Add<HLoadNamedField>( |
| 1863 context(), nullptr, | 1863 context(), nullptr, |
| 1864 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); | 1864 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); |
| 1865 HValue* native_context = Add<HLoadNamedField>( | 1865 HValue* native_context = Add<HLoadNamedField>( |
| 1866 global_object, nullptr, HObjectAccess::ForGlobalObjectNativeContext()); | 1866 global_object, nullptr, HObjectAccess::ForJSGlobalObjectNativeContext()); |
| 1867 Add<HStoreNamedField>( | 1867 Add<HStoreNamedField>( |
| 1868 result, HObjectAccess::ForMap(), | 1868 result, HObjectAccess::ForMap(), |
| 1869 Add<HLoadNamedField>( | 1869 Add<HLoadNamedField>( |
| 1870 native_context, nullptr, | 1870 native_context, nullptr, |
| 1871 HObjectAccess::ForContextSlot(Context::REGEXP_RESULT_MAP_INDEX))); | 1871 HObjectAccess::ForContextSlot(Context::REGEXP_RESULT_MAP_INDEX))); |
| 1872 HConstant* empty_fixed_array = | 1872 HConstant* empty_fixed_array = |
| 1873 Add<HConstant>(isolate()->factory()->empty_fixed_array()); | 1873 Add<HConstant>(isolate()->factory()->empty_fixed_array()); |
| 1874 Add<HStoreNamedField>( | 1874 Add<HStoreNamedField>( |
| 1875 result, HObjectAccess::ForJSArrayOffset(JSArray::kPropertiesOffset), | 1875 result, HObjectAccess::ForJSArrayOffset(JSArray::kPropertiesOffset), |
| 1876 empty_fixed_array); | 1876 empty_fixed_array); |
| (...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3259 } | 3259 } |
| 3260 | 3260 |
| 3261 | 3261 |
| 3262 HInstruction* HGraphBuilder::BuildGetNativeContext() { | 3262 HInstruction* HGraphBuilder::BuildGetNativeContext() { |
| 3263 // Get the global object, then the native context | 3263 // Get the global object, then the native context |
| 3264 HValue* global_object = Add<HLoadNamedField>( | 3264 HValue* global_object = Add<HLoadNamedField>( |
| 3265 context(), nullptr, | 3265 context(), nullptr, |
| 3266 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); | 3266 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); |
| 3267 return Add<HLoadNamedField>(global_object, nullptr, | 3267 return Add<HLoadNamedField>(global_object, nullptr, |
| 3268 HObjectAccess::ForObservableJSObjectOffset( | 3268 HObjectAccess::ForObservableJSObjectOffset( |
| 3269 GlobalObject::kNativeContextOffset)); | 3269 JSGlobalObject::kNativeContextOffset)); |
| 3270 } | 3270 } |
| 3271 | 3271 |
| 3272 | 3272 |
| 3273 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) { | 3273 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) { |
| 3274 // Get the global object, then the native context | 3274 // Get the global object, then the native context |
| 3275 HInstruction* context = Add<HLoadNamedField>( | 3275 HInstruction* context = Add<HLoadNamedField>( |
| 3276 closure, nullptr, HObjectAccess::ForFunctionContextPointer()); | 3276 closure, nullptr, HObjectAccess::ForFunctionContextPointer()); |
| 3277 HInstruction* global_object = Add<HLoadNamedField>( | 3277 HInstruction* global_object = Add<HLoadNamedField>( |
| 3278 context, nullptr, | 3278 context, nullptr, |
| 3279 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); | 3279 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); |
| 3280 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset( | 3280 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset( |
| 3281 GlobalObject::kNativeContextOffset); | 3281 JSGlobalObject::kNativeContextOffset); |
| 3282 return Add<HLoadNamedField>(global_object, nullptr, access); | 3282 return Add<HLoadNamedField>(global_object, nullptr, access); |
| 3283 } | 3283 } |
| 3284 | 3284 |
| 3285 | 3285 |
| 3286 HInstruction* HGraphBuilder::BuildGetScriptContext(int context_index) { | 3286 HInstruction* HGraphBuilder::BuildGetScriptContext(int context_index) { |
| 3287 HValue* native_context = BuildGetNativeContext(); | 3287 HValue* native_context = BuildGetNativeContext(); |
| 3288 HValue* script_context_table = Add<HLoadNamedField>( | 3288 HValue* script_context_table = Add<HLoadNamedField>( |
| 3289 native_context, nullptr, | 3289 native_context, nullptr, |
| 3290 HObjectAccess::ForContextSlot(Context::SCRIPT_CONTEXT_TABLE_INDEX)); | 3290 HObjectAccess::ForContextSlot(Context::SCRIPT_CONTEXT_TABLE_INDEX)); |
| 3291 return Add<HLoadNamedField>(script_context_table, nullptr, | 3291 return Add<HLoadNamedField>(script_context_table, nullptr, |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3547 | 3547 |
| 3548 return array_object; | 3548 return array_object; |
| 3549 } | 3549 } |
| 3550 | 3550 |
| 3551 | 3551 |
| 3552 HValue* HGraphBuilder::AddLoadJSBuiltin(int context_index) { | 3552 HValue* HGraphBuilder::AddLoadJSBuiltin(int context_index) { |
| 3553 HValue* global_object = Add<HLoadNamedField>( | 3553 HValue* global_object = Add<HLoadNamedField>( |
| 3554 context(), nullptr, | 3554 context(), nullptr, |
| 3555 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); | 3555 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); |
| 3556 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset( | 3556 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset( |
| 3557 GlobalObject::kNativeContextOffset); | 3557 JSGlobalObject::kNativeContextOffset); |
| 3558 HValue* native_context = Add<HLoadNamedField>(global_object, nullptr, access); | 3558 HValue* native_context = Add<HLoadNamedField>(global_object, nullptr, access); |
| 3559 HObjectAccess function_access = HObjectAccess::ForContextSlot(context_index); | 3559 HObjectAccess function_access = HObjectAccess::ForContextSlot(context_index); |
| 3560 return Add<HLoadNamedField>(native_context, nullptr, function_access); | 3560 return Add<HLoadNamedField>(native_context, nullptr, function_access); |
| 3561 } | 3561 } |
| 3562 | 3562 |
| 3563 | 3563 |
| 3564 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) | 3564 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) |
| 3565 : HGraphBuilder(info), | 3565 : HGraphBuilder(info), |
| 3566 function_state_(NULL), | 3566 function_state_(NULL), |
| 3567 initial_function_state_(this, info, NORMAL_RETURN, 0), | 3567 initial_function_state_(this, info, NORMAL_RETURN, 0), |
| (...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5627 } | 5627 } |
| 5628 // Handle known global constants like 'undefined' specially to avoid a | 5628 // Handle known global constants like 'undefined' specially to avoid a |
| 5629 // load from a global cell for them. | 5629 // load from a global cell for them. |
| 5630 Handle<Object> constant_value = | 5630 Handle<Object> constant_value = |
| 5631 isolate()->factory()->GlobalConstantFor(variable->name()); | 5631 isolate()->factory()->GlobalConstantFor(variable->name()); |
| 5632 if (!constant_value.is_null()) { | 5632 if (!constant_value.is_null()) { |
| 5633 HConstant* instr = New<HConstant>(constant_value); | 5633 HConstant* instr = New<HConstant>(constant_value); |
| 5634 return ast_context()->ReturnInstruction(instr, expr->id()); | 5634 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 5635 } | 5635 } |
| 5636 | 5636 |
| 5637 Handle<GlobalObject> global(current_info()->global_object()); | 5637 Handle<JSGlobalObject> global(current_info()->global_object()); |
| 5638 | 5638 |
| 5639 // Lookup in script contexts. | 5639 // Lookup in script contexts. |
| 5640 { | 5640 { |
| 5641 Handle<ScriptContextTable> script_contexts( | 5641 Handle<ScriptContextTable> script_contexts( |
| 5642 global->native_context()->script_context_table()); | 5642 global->native_context()->script_context_table()); |
| 5643 ScriptContextTable::LookupResult lookup; | 5643 ScriptContextTable::LookupResult lookup; |
| 5644 if (ScriptContextTable::Lookup(script_contexts, variable->name(), | 5644 if (ScriptContextTable::Lookup(script_contexts, variable->name(), |
| 5645 &lookup)) { | 5645 &lookup)) { |
| 5646 Handle<Context> script_context = ScriptContextTable::GetContext( | 5646 Handle<Context> script_context = ScriptContextTable::GetContext( |
| 5647 script_contexts, lookup.context_index); | 5647 script_contexts, lookup.context_index); |
| (...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6836 BuildStore(expr, prop, expr->AssignmentSlot(), expr->id(), | 6836 BuildStore(expr, prop, expr->AssignmentSlot(), expr->id(), |
| 6837 expr->AssignmentId(), expr->IsUninitialized()); | 6837 expr->AssignmentId(), expr->IsUninitialized()); |
| 6838 } | 6838 } |
| 6839 | 6839 |
| 6840 | 6840 |
| 6841 // Because not every expression has a position and there is not common | 6841 // Because not every expression has a position and there is not common |
| 6842 // superclass of Assignment and CountOperation, we cannot just pass the | 6842 // superclass of Assignment and CountOperation, we cannot just pass the |
| 6843 // owning expression instead of position and ast_id separately. | 6843 // owning expression instead of position and ast_id separately. |
| 6844 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( | 6844 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( |
| 6845 Variable* var, HValue* value, FeedbackVectorSlot slot, BailoutId ast_id) { | 6845 Variable* var, HValue* value, FeedbackVectorSlot slot, BailoutId ast_id) { |
| 6846 Handle<GlobalObject> global(current_info()->global_object()); | 6846 Handle<JSGlobalObject> global(current_info()->global_object()); |
| 6847 | 6847 |
| 6848 // Lookup in script contexts. | 6848 // Lookup in script contexts. |
| 6849 { | 6849 { |
| 6850 Handle<ScriptContextTable> script_contexts( | 6850 Handle<ScriptContextTable> script_contexts( |
| 6851 global->native_context()->script_context_table()); | 6851 global->native_context()->script_context_table()); |
| 6852 ScriptContextTable::LookupResult lookup; | 6852 ScriptContextTable::LookupResult lookup; |
| 6853 if (ScriptContextTable::Lookup(script_contexts, var->name(), &lookup)) { | 6853 if (ScriptContextTable::Lookup(script_contexts, var->name(), &lookup)) { |
| 6854 if (lookup.mode == CONST) { | 6854 if (lookup.mode == CONST) { |
| 6855 return Bailout(kNonInitializerAssignmentToConst); | 6855 return Bailout(kNonInitializerAssignmentToConst); |
| 6856 } | 6856 } |
| (...skipping 3169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10026 byte_length = AddUncasted<HForceRepresentation>( | 10026 byte_length = AddUncasted<HForceRepresentation>( |
| 10027 byte_length, byte_length_access.representation()); | 10027 byte_length, byte_length_access.representation()); |
| 10028 HAllocate* result = | 10028 HAllocate* result = |
| 10029 BuildAllocate(Add<HConstant>(JSArrayBuffer::kSizeWithInternalFields), | 10029 BuildAllocate(Add<HConstant>(JSArrayBuffer::kSizeWithInternalFields), |
| 10030 HType::JSObject(), JS_ARRAY_BUFFER_TYPE, HAllocationMode()); | 10030 HType::JSObject(), JS_ARRAY_BUFFER_TYPE, HAllocationMode()); |
| 10031 | 10031 |
| 10032 HValue* global_object = Add<HLoadNamedField>( | 10032 HValue* global_object = Add<HLoadNamedField>( |
| 10033 context(), nullptr, | 10033 context(), nullptr, |
| 10034 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); | 10034 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); |
| 10035 HValue* native_context = Add<HLoadNamedField>( | 10035 HValue* native_context = Add<HLoadNamedField>( |
| 10036 global_object, nullptr, HObjectAccess::ForGlobalObjectNativeContext()); | 10036 global_object, nullptr, HObjectAccess::ForJSGlobalObjectNativeContext()); |
| 10037 Add<HStoreNamedField>( | 10037 Add<HStoreNamedField>( |
| 10038 result, HObjectAccess::ForMap(), | 10038 result, HObjectAccess::ForMap(), |
| 10039 Add<HLoadNamedField>( | 10039 Add<HLoadNamedField>( |
| 10040 native_context, nullptr, | 10040 native_context, nullptr, |
| 10041 HObjectAccess::ForContextSlot(Context::ARRAY_BUFFER_MAP_INDEX))); | 10041 HObjectAccess::ForContextSlot(Context::ARRAY_BUFFER_MAP_INDEX))); |
| 10042 | 10042 |
| 10043 HConstant* empty_fixed_array = | 10043 HConstant* empty_fixed_array = |
| 10044 Add<HConstant>(isolate()->factory()->empty_fixed_array()); | 10044 Add<HConstant>(isolate()->factory()->empty_fixed_array()); |
| 10045 Add<HStoreNamedField>( | 10045 Add<HStoreNamedField>( |
| 10046 result, HObjectAccess::ForJSArrayOffset(JSArray::kPropertiesOffset), | 10046 result, HObjectAccess::ForJSArrayOffset(JSArray::kPropertiesOffset), |
| (...skipping 3632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13679 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13679 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13680 } | 13680 } |
| 13681 | 13681 |
| 13682 #ifdef DEBUG | 13682 #ifdef DEBUG |
| 13683 graph_->Verify(false); // No full verify. | 13683 graph_->Verify(false); // No full verify. |
| 13684 #endif | 13684 #endif |
| 13685 } | 13685 } |
| 13686 | 13686 |
| 13687 } // namespace internal | 13687 } // namespace internal |
| 13688 } // namespace v8 | 13688 } // namespace v8 |
| OLD | NEW |