Chromium Code Reviews| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 | 197 |
| 198 | 198 |
| 199 template <class Stub> | 199 template <class Stub> |
| 200 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase { | 200 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase { |
| 201 public: | 201 public: |
| 202 explicit CodeStubGraphBuilder(Stub* stub) | 202 explicit CodeStubGraphBuilder(Stub* stub) |
| 203 : CodeStubGraphBuilderBase(Isolate::Current(), stub) {} | 203 : CodeStubGraphBuilderBase(Isolate::Current(), stub) {} |
| 204 | 204 |
| 205 protected: | 205 protected: |
| 206 virtual HValue* BuildCodeStub() { | 206 virtual HValue* BuildCodeStub() { |
| 207 if (casted_stub()->IsMiss()) { | 207 if (casted_stub()->IsUninitialized()) { |
| 208 return BuildCodeUninitializedStub(); | |
| 209 } else { | |
| 208 return BuildCodeInitializedStub(); | 210 return BuildCodeInitializedStub(); |
|
Toon Verwaest
2013/05/24 10:59:17
Nice catch. So confusing.
| |
| 209 } else { | |
| 210 return BuildCodeUninitializedStub(); | |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 virtual HValue* BuildCodeInitializedStub() { | 214 virtual HValue* BuildCodeInitializedStub() { |
| 215 UNIMPLEMENTED(); | 215 UNIMPLEMENTED(); |
| 216 return NULL; | 216 return NULL; |
| 217 } | 217 } |
| 218 | 218 |
| 219 virtual HValue* BuildCodeUninitializedStub() { | 219 virtual HValue* BuildCodeUninitializedStub() { |
| 220 // Force a deopt that falls back to the runtime. | 220 // Force a deopt that falls back to the runtime. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 template <class Stub> | 269 template <class Stub> |
| 270 static Handle<Code> DoGenerateCode(Stub* stub) { | 270 static Handle<Code> DoGenerateCode(Stub* stub) { |
| 271 Isolate* isolate = Isolate::Current(); | 271 Isolate* isolate = Isolate::Current(); |
| 272 CodeStub::Major major_key = | 272 CodeStub::Major major_key = |
| 273 static_cast<HydrogenCodeStub*>(stub)->MajorKey(); | 273 static_cast<HydrogenCodeStub*>(stub)->MajorKey(); |
| 274 CodeStubInterfaceDescriptor* descriptor = | 274 CodeStubInterfaceDescriptor* descriptor = |
| 275 isolate->code_stub_interface_descriptor(major_key); | 275 isolate->code_stub_interface_descriptor(major_key); |
| 276 if (descriptor->register_param_count_ < 0) { | 276 if (descriptor->register_param_count_ < 0) { |
| 277 stub->InitializeInterfaceDescriptor(isolate, descriptor); | 277 stub->InitializeInterfaceDescriptor(isolate, descriptor); |
| 278 } | 278 } |
| 279 // The miss case without stack parameters can use a light-weight stub to enter | 279 |
| 280 // If we are uninitialized we can use a light-weight stub to enter | |
| 280 // the runtime that is significantly faster than using the standard | 281 // the runtime that is significantly faster than using the standard |
| 281 // stub-failure deopt mechanism. | 282 // stub-failure deopt mechanism. |
| 282 if (stub->IsMiss() && descriptor->stack_parameter_count_ == NULL) { | 283 if (stub->IsUninitialized() && descriptor->has_miss_handler()) { |
| 284 ASSERT(descriptor->stack_parameter_count_ == NULL); | |
| 283 return stub->GenerateLightweightMissCode(isolate); | 285 return stub->GenerateLightweightMissCode(isolate); |
| 284 } else { | |
| 285 CodeStubGraphBuilder<Stub> builder(stub); | |
| 286 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); | |
| 287 return chunk->Codegen(); | |
| 288 } | 286 } |
| 287 CodeStubGraphBuilder<Stub> builder(stub); | |
| 288 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); | |
| 289 return chunk->Codegen(); | |
| 289 } | 290 } |
| 290 | 291 |
| 291 | 292 |
| 292 template <> | 293 template <> |
| 293 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { | 294 HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { |
| 294 Zone* zone = this->zone(); | 295 Zone* zone = this->zone(); |
| 295 Factory* factory = isolate()->factory(); | 296 Factory* factory = isolate()->factory(); |
| 296 HValue* undefined = graph()->GetConstantUndefined(); | 297 HValue* undefined = graph()->GetConstantUndefined(); |
| 297 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); | 298 AllocationSiteMode alloc_site_mode = casted_stub()->allocation_site_mode(); |
| 298 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); | 299 FastCloneShallowArrayStub::Mode mode = casted_stub()->mode(); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 return new_object; | 670 return new_object; |
| 670 } | 671 } |
| 671 | 672 |
| 672 | 673 |
| 673 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { | 674 Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() { |
| 674 return DoGenerateCode(this); | 675 return DoGenerateCode(this); |
| 675 } | 676 } |
| 676 | 677 |
| 677 | 678 |
| 678 template <> | 679 template <> |
| 679 HValue* CodeStubGraphBuilder<CompareNilICStub>::BuildCodeUninitializedStub() { | 680 HValue* CodeStubGraphBuilder<CompareNilICStub>::BuildCodeInitializedStub() { |
| 680 CompareNilICStub* stub = casted_stub(); | 681 CompareNilICStub* stub = casted_stub(); |
| 681 HIfContinuation continuation; | 682 HIfContinuation continuation; |
| 682 Handle<Map> sentinel_map(graph()->isolate()->heap()->meta_map()); | 683 Handle<Map> sentinel_map(graph()->isolate()->heap()->meta_map()); |
| 683 BuildCompareNil(GetParameter(0), stub->GetKind(), | 684 BuildCompareNil(GetParameter(0), stub->GetKind(), |
| 684 stub->GetTypes(), sentinel_map, | 685 stub->GetTypes(), sentinel_map, |
| 685 RelocInfo::kNoPosition, &continuation); | 686 RelocInfo::kNoPosition, &continuation); |
| 686 IfBuilder if_nil(this, &continuation); | 687 IfBuilder if_nil(this, &continuation); |
| 687 if_nil.Then(); | 688 if_nil.Then(); |
| 688 if (continuation.IsFalseReachable()) { | 689 if (continuation.IsFalseReachable()) { |
| 689 if_nil.Else(); | 690 if_nil.Else(); |
| 690 if_nil.Return(graph()->GetConstantSmi0()); | 691 if_nil.Return(graph()->GetConstantSmi0()); |
| 691 } | 692 } |
| 692 if_nil.End(); | 693 if_nil.End(); |
| 693 return continuation.IsTrueReachable() | 694 return continuation.IsTrueReachable() |
| 694 ? graph()->GetConstantSmi1() | 695 ? graph()->GetConstantSmi1() |
| 695 : graph()->GetConstantUndefined(); | 696 : graph()->GetConstantUndefined(); |
| 696 } | 697 } |
| 697 | 698 |
| 698 | 699 |
| 699 Handle<Code> CompareNilICStub::GenerateCode() { | 700 Handle<Code> CompareNilICStub::GenerateCode() { |
| 700 return DoGenerateCode(this); | 701 return DoGenerateCode(this); |
| 701 } | 702 } |
| 702 | 703 |
| 703 } } // namespace v8::internal | 704 } } // namespace v8::internal |
| OLD | NEW |