| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 CompilationInfoWithZone info_; | 122 CompilationInfoWithZone info_; |
| 123 CodeStubInterfaceDescriptor* descriptor_; | 123 CodeStubInterfaceDescriptor* descriptor_; |
| 124 HContext* context_; | 124 HContext* context_; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 | 127 |
| 128 bool CodeStubGraphBuilderBase::BuildGraph() { | 128 bool CodeStubGraphBuilderBase::BuildGraph() { |
| 129 // Update the static counter each time a new code stub is generated. | 129 // Update the static counter each time a new code stub is generated. |
| 130 isolate()->counters()->code_stubs()->Increment(); | 130 isolate()->counters()->code_stubs()->Increment(); |
| 131 | 131 |
| 132 if (FLAG_trace_hydrogen) { | 132 if (FLAG_trace_hydrogen_stubs) { |
| 133 const char* name = CodeStub::MajorName(stub()->MajorKey(), false); | 133 const char* name = CodeStub::MajorName(stub()->MajorKey(), false); |
| 134 PrintF("-----------------------------------------------------------\n"); | 134 PrintF("-----------------------------------------------------------\n"); |
| 135 PrintF("Compiling stub %s using hydrogen\n", name); | 135 PrintF("Compiling stub %s using hydrogen\n", name); |
| 136 isolate()->GetHTracer()->TraceCompilation(&info_); | 136 isolate()->GetHTracer()->TraceCompilation(&info_); |
| 137 } | 137 } |
| 138 | 138 |
| 139 Zone* zone = this->zone(); | 139 Zone* zone = this->zone(); |
| 140 int param_count = descriptor_->register_param_count_; | 140 int param_count = descriptor_->register_param_count_; |
| 141 HEnvironment* start_environment = graph()->start_environment(); | 141 HEnvironment* start_environment = graph()->start_environment(); |
| 142 HBasicBlock* next_block = CreateBasicBlock(start_environment); | 142 HBasicBlock* next_block = CreateBasicBlock(start_environment); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 171 } else { | 171 } else { |
| 172 ASSERT(descriptor_->environment_length() == param_count); | 172 ASSERT(descriptor_->environment_length() == param_count); |
| 173 stack_parameter_count = graph()->GetConstantMinus1(); | 173 stack_parameter_count = graph()->GetConstantMinus1(); |
| 174 arguments_length_ = graph()->GetConstant0(); | 174 arguments_length_ = graph()->GetConstant0(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 context_ = new(zone) HContext(); | 177 context_ = new(zone) HContext(); |
| 178 AddInstruction(context_); | 178 AddInstruction(context_); |
| 179 start_environment->BindContext(context_); | 179 start_environment->BindContext(context_); |
| 180 | 180 |
| 181 AddSimulate(BailoutId::StubEntry()); | 181 Add<HSimulate>(BailoutId::StubEntry()); |
| 182 | 182 |
| 183 NoObservableSideEffectsScope no_effects(this); | 183 NoObservableSideEffectsScope no_effects(this); |
| 184 | 184 |
| 185 HValue* return_value = BuildCodeStub(); | 185 HValue* return_value = BuildCodeStub(); |
| 186 | 186 |
| 187 // We might have extra expressions to pop from the stack in addition to the | 187 // We might have extra expressions to pop from the stack in addition to the |
| 188 // arguments above. | 188 // arguments above. |
| 189 HInstruction* stack_pop_count = stack_parameter_count; | 189 HInstruction* stack_pop_count = stack_parameter_count; |
| 190 if (descriptor_->function_mode_ == JS_FUNCTION_STUB_MODE) { | 190 if (descriptor_->function_mode_ == JS_FUNCTION_STUB_MODE) { |
| 191 if (!stack_parameter_count->IsConstant() && | 191 if (!stack_parameter_count->IsConstant() && |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 } else { | 390 } else { |
| 391 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); | 391 ElementsKind elements_kind = casted_stub()->ComputeElementsKind(); |
| 392 environment()->Push(BuildCloneShallowArray(context(), | 392 environment()->Push(BuildCloneShallowArray(context(), |
| 393 boilerplate, | 393 boilerplate, |
| 394 allocation_site, | 394 allocation_site, |
| 395 alloc_site_mode, | 395 alloc_site_mode, |
| 396 elements_kind, | 396 elements_kind, |
| 397 length)); | 397 length)); |
| 398 } | 398 } |
| 399 | 399 |
| 400 HValue* result = environment()->Pop(); | |
| 401 checker.ElseDeopt(); | 400 checker.ElseDeopt(); |
| 402 return result; | 401 checker.End(); |
| 402 |
| 403 return environment()->Pop(); |
| 403 } | 404 } |
| 404 | 405 |
| 405 | 406 |
| 406 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { | 407 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { |
| 407 return DoGenerateCode(this); | 408 return DoGenerateCode(this); |
| 408 } | 409 } |
| 409 | 410 |
| 410 | 411 |
| 411 template <> | 412 template <> |
| 412 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { | 413 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 440 } | 441 } |
| 441 | 442 |
| 442 HInstruction* object = AddInstruction(new(zone) | 443 HInstruction* object = AddInstruction(new(zone) |
| 443 HAllocate(context(), size_in_bytes, HType::JSObject(), flags)); | 444 HAllocate(context(), size_in_bytes, HType::JSObject(), flags)); |
| 444 | 445 |
| 445 for (int i = 0; i < size; i += kPointerSize) { | 446 for (int i = 0; i < size; i += kPointerSize) { |
| 446 HObjectAccess access = HObjectAccess::ForJSObjectOffset(i); | 447 HObjectAccess access = HObjectAccess::ForJSObjectOffset(i); |
| 447 AddStore(object, access, AddLoad(boilerplate, access)); | 448 AddStore(object, access, AddLoad(boilerplate, access)); |
| 448 } | 449 } |
| 449 | 450 |
| 451 environment()->Push(object); |
| 450 checker.ElseDeopt(); | 452 checker.ElseDeopt(); |
| 451 return object; | 453 checker.End(); |
| 454 |
| 455 return environment()->Pop(); |
| 452 } | 456 } |
| 453 | 457 |
| 454 | 458 |
| 455 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { | 459 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { |
| 456 return DoGenerateCode(this); | 460 return DoGenerateCode(this); |
| 457 } | 461 } |
| 458 | 462 |
| 459 | 463 |
| 460 template <> | 464 template <> |
| 461 HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() { | 465 HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 } | 514 } |
| 511 | 515 |
| 512 | 516 |
| 513 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { | 517 Handle<Code> KeyedLoadFastElementStub::GenerateCode() { |
| 514 return DoGenerateCode(this); | 518 return DoGenerateCode(this); |
| 515 } | 519 } |
| 516 | 520 |
| 517 | 521 |
| 518 template<> | 522 template<> |
| 519 HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() { | 523 HValue* CodeStubGraphBuilder<LoadFieldStub>::BuildCodeStub() { |
| 524 Representation rep = casted_stub()->representation(); |
| 520 HObjectAccess access = casted_stub()->is_inobject() ? | 525 HObjectAccess access = casted_stub()->is_inobject() ? |
| 521 HObjectAccess::ForJSObjectOffset(casted_stub()->offset()) : | 526 HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) : |
| 522 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset()); | 527 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep); |
| 523 return AddInstruction(BuildLoadNamedField(GetParameter(0), access, | 528 return AddInstruction(BuildLoadNamedField(GetParameter(0), access)); |
| 524 casted_stub()->representation())); | |
| 525 } | 529 } |
| 526 | 530 |
| 527 | 531 |
| 528 Handle<Code> LoadFieldStub::GenerateCode() { | 532 Handle<Code> LoadFieldStub::GenerateCode() { |
| 529 return DoGenerateCode(this); | 533 return DoGenerateCode(this); |
| 530 } | 534 } |
| 531 | 535 |
| 532 | 536 |
| 533 template<> | 537 template<> |
| 534 HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() { | 538 HValue* CodeStubGraphBuilder<KeyedLoadFieldStub>::BuildCodeStub() { |
| 539 Representation rep = casted_stub()->representation(); |
| 535 HObjectAccess access = casted_stub()->is_inobject() ? | 540 HObjectAccess access = casted_stub()->is_inobject() ? |
| 536 HObjectAccess::ForJSObjectOffset(casted_stub()->offset()) : | 541 HObjectAccess::ForJSObjectOffset(casted_stub()->offset(), rep) : |
| 537 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset()); | 542 HObjectAccess::ForBackingStoreOffset(casted_stub()->offset(), rep); |
| 538 return AddInstruction(BuildLoadNamedField(GetParameter(0), access, | 543 return AddInstruction(BuildLoadNamedField(GetParameter(0), access)); |
| 539 casted_stub()->representation())); | |
| 540 } | 544 } |
| 541 | 545 |
| 542 | 546 |
| 543 Handle<Code> KeyedLoadFieldStub::GenerateCode() { | 547 Handle<Code> KeyedLoadFieldStub::GenerateCode() { |
| 544 return DoGenerateCode(this); | 548 return DoGenerateCode(this); |
| 545 } | 549 } |
| 546 | 550 |
| 547 | 551 |
| 548 template <> | 552 template <> |
| 549 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() { | 553 HValue* CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() { |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 Handle<Object> placeholer_value(Smi::FromInt(0), isolate()); | 881 Handle<Object> placeholer_value(Smi::FromInt(0), isolate()); |
| 878 Handle<PropertyCell> placeholder_cell = | 882 Handle<PropertyCell> placeholder_cell = |
| 879 isolate()->factory()->NewPropertyCell(placeholer_value); | 883 isolate()->factory()->NewPropertyCell(placeholer_value); |
| 880 | 884 |
| 881 HParameter* receiver = GetParameter(0); | 885 HParameter* receiver = GetParameter(0); |
| 882 HParameter* value = GetParameter(2); | 886 HParameter* value = GetParameter(2); |
| 883 | 887 |
| 884 // Check that the map of the global has not changed: use a placeholder map | 888 // Check that the map of the global has not changed: use a placeholder map |
| 885 // that will be replaced later with the global object's map. | 889 // that will be replaced later with the global object's map. |
| 886 Handle<Map> placeholder_map = isolate()->factory()->meta_map(); | 890 Handle<Map> placeholder_map = isolate()->factory()->meta_map(); |
| 887 AddInstruction(HCheckMaps::New(receiver, placeholder_map, zone())); | 891 AddInstruction(HCheckMaps::New( |
| 892 receiver, placeholder_map, zone(), top_info())); |
| 888 | 893 |
| 889 HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged()); | 894 HValue* cell = Add<HConstant>(placeholder_cell, Representation::Tagged()); |
| 890 HObjectAccess access(HObjectAccess::ForCellPayload(isolate())); | 895 HObjectAccess access(HObjectAccess::ForCellPayload(isolate())); |
| 891 HValue* cell_contents = Add<HLoadNamedField>(cell, access); | 896 HValue* cell_contents = Add<HLoadNamedField>(cell, access); |
| 892 | 897 |
| 893 if (stub->is_constant()) { | 898 if (stub->is_constant()) { |
| 894 IfBuilder builder(this); | 899 IfBuilder builder(this); |
| 895 builder.If<HCompareObjectEqAndBranch>(cell_contents, value); | 900 builder.If<HCompareObjectEqAndBranch>(cell_contents, value); |
| 896 builder.Then(); | 901 builder.Then(); |
| 897 builder.ElseDeopt(); | 902 builder.ElseDeopt(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 921 | 926 |
| 922 template<> | 927 template<> |
| 923 HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() { | 928 HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() { |
| 924 HValue* value = GetParameter(0); | 929 HValue* value = GetParameter(0); |
| 925 HValue* map = GetParameter(1); | 930 HValue* map = GetParameter(1); |
| 926 HValue* key = GetParameter(2); | 931 HValue* key = GetParameter(2); |
| 927 HValue* object = GetParameter(3); | 932 HValue* object = GetParameter(3); |
| 928 | 933 |
| 929 if (FLAG_trace_elements_transitions) { | 934 if (FLAG_trace_elements_transitions) { |
| 930 // Tracing elements transitions is the job of the runtime. | 935 // Tracing elements transitions is the job of the runtime. |
| 931 current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll); | 936 Add<HDeoptimize>(Deoptimizer::EAGER); |
| 932 set_current_block(NULL); | |
| 933 } else { | 937 } else { |
| 934 info()->MarkAsSavesCallerDoubles(); | 938 info()->MarkAsSavesCallerDoubles(); |
| 935 | 939 |
| 936 BuildTransitionElementsKind(object, map, | 940 BuildTransitionElementsKind(object, map, |
| 937 casted_stub()->from_kind(), | 941 casted_stub()->from_kind(), |
| 938 casted_stub()->to_kind(), | 942 casted_stub()->to_kind(), |
| 939 casted_stub()->is_jsarray()); | 943 casted_stub()->is_jsarray()); |
| 940 | 944 |
| 941 BuildUncheckedMonomorphicElementAccess(object, key, value, NULL, | 945 BuildUncheckedMonomorphicElementAccess(object, key, value, NULL, |
| 942 casted_stub()->is_jsarray(), | 946 casted_stub()->is_jsarray(), |
| 943 casted_stub()->to_kind(), | 947 casted_stub()->to_kind(), |
| 944 true, ALLOW_RETURN_HOLE, | 948 true, ALLOW_RETURN_HOLE, |
| 945 casted_stub()->store_mode()); | 949 casted_stub()->store_mode()); |
| 946 } | 950 } |
| 947 | 951 |
| 948 return value; | 952 return value; |
| 949 } | 953 } |
| 950 | 954 |
| 951 | 955 |
| 952 Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() { | 956 Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() { |
| 953 return DoGenerateCode(this); | 957 return DoGenerateCode(this); |
| 954 } | 958 } |
| 955 | 959 |
| 956 | 960 |
| 957 } } // namespace v8::internal | 961 } } // namespace v8::internal |
| OLD | NEW |