OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/field-index.h" | 8 #include "src/field-index.h" |
9 #include "src/hydrogen.h" | 9 #include "src/hydrogen.h" |
10 #include "src/lithium.h" | 10 #include "src/lithium.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 HValue* native_context); | 96 HValue* native_context); |
97 | 97 |
98 private: | 98 private: |
99 HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder); | 99 HValue* BuildArraySingleArgumentConstructor(JSArrayBuilder* builder); |
100 HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder, | 100 HValue* BuildArrayNArgumentsConstructor(JSArrayBuilder* builder, |
101 ElementsKind kind); | 101 ElementsKind kind); |
102 | 102 |
103 SmartArrayPointer<HParameter*> parameters_; | 103 SmartArrayPointer<HParameter*> parameters_; |
104 HValue* arguments_length_; | 104 HValue* arguments_length_; |
105 CompilationInfoWithZone info_; | 105 CompilationInfoWithZone info_; |
106 CodeStubInterfaceDescriptor descriptor_; | 106 CodeStubDescriptor descriptor_; |
107 HContext* context_; | 107 HContext* context_; |
108 }; | 108 }; |
109 | 109 |
110 | 110 |
111 bool CodeStubGraphBuilderBase::BuildGraph() { | 111 bool CodeStubGraphBuilderBase::BuildGraph() { |
112 // Update the static counter each time a new code stub is generated. | 112 // Update the static counter each time a new code stub is generated. |
113 isolate()->counters()->code_stubs()->Increment(); | 113 isolate()->counters()->code_stubs()->Increment(); |
114 | 114 |
115 if (FLAG_trace_hydrogen_stubs) { | 115 if (FLAG_trace_hydrogen_stubs) { |
116 const char* name = CodeStub::MajorName(stub()->MajorKey(), false); | 116 const char* name = CodeStub::MajorName(stub()->MajorKey(), false); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 builder.IfNot<HCompareObjectEqAndBranch, HValue*>(undefined, undefined); | 209 builder.IfNot<HCompareObjectEqAndBranch, HValue*>(undefined, undefined); |
210 builder.Then(); | 210 builder.Then(); |
211 builder.ElseDeopt("Forced deopt to runtime"); | 211 builder.ElseDeopt("Forced deopt to runtime"); |
212 return undefined; | 212 return undefined; |
213 } | 213 } |
214 | 214 |
215 Stub* casted_stub() { return static_cast<Stub*>(stub()); } | 215 Stub* casted_stub() { return static_cast<Stub*>(stub()); } |
216 }; | 216 }; |
217 | 217 |
218 | 218 |
219 Handle<Code> HydrogenCodeStub::GenerateLightweightMissCode() { | 219 Handle<Code> HydrogenCodeStub::GenerateLightweightMissCode( |
| 220 ExternalReference miss) { |
220 Factory* factory = isolate()->factory(); | 221 Factory* factory = isolate()->factory(); |
221 | 222 |
222 // Generate the new code. | 223 // Generate the new code. |
223 MacroAssembler masm(isolate(), NULL, 256); | 224 MacroAssembler masm(isolate(), NULL, 256); |
224 | 225 |
225 { | 226 { |
226 // Update the static counter each time a new code stub is generated. | 227 // Update the static counter each time a new code stub is generated. |
227 isolate()->counters()->code_stubs()->Increment(); | 228 isolate()->counters()->code_stubs()->Increment(); |
228 | 229 |
229 // Generate the code for the stub. | 230 // Generate the code for the stub. |
230 masm.set_generating_stub(true); | 231 masm.set_generating_stub(true); |
231 NoCurrentFrameScope scope(&masm); | 232 NoCurrentFrameScope scope(&masm); |
232 GenerateLightweightMiss(&masm); | 233 GenerateLightweightMiss(&masm, miss); |
233 } | 234 } |
234 | 235 |
235 // Create the code object. | 236 // Create the code object. |
236 CodeDesc desc; | 237 CodeDesc desc; |
237 masm.GetCode(&desc); | 238 masm.GetCode(&desc); |
238 | 239 |
239 // Copy the generated code into a heap object. | 240 // Copy the generated code into a heap object. |
240 Code::Flags flags = Code::ComputeFlags( | 241 Code::Flags flags = Code::ComputeFlags( |
241 GetCodeKind(), | 242 GetCodeKind(), |
242 GetICState(), | 243 GetICState(), |
243 GetExtraICState(), | 244 GetExtraICState(), |
244 GetStubType()); | 245 GetStubType()); |
245 Handle<Code> new_object = factory->NewCode( | 246 Handle<Code> new_object = factory->NewCode( |
246 desc, flags, masm.CodeObject(), NeedsImmovableCode()); | 247 desc, flags, masm.CodeObject(), NeedsImmovableCode()); |
247 return new_object; | 248 return new_object; |
248 } | 249 } |
249 | 250 |
250 | 251 |
251 template <class Stub> | 252 template <class Stub> |
252 static Handle<Code> DoGenerateCode(Stub* stub) { | 253 static Handle<Code> DoGenerateCode(Stub* stub) { |
253 Isolate* isolate = stub->isolate(); | 254 Isolate* isolate = stub->isolate(); |
254 CodeStubInterfaceDescriptor descriptor(stub); | 255 CodeStubDescriptor descriptor(stub); |
255 | 256 |
256 // If we are uninitialized we can use a light-weight stub to enter | 257 // If we are uninitialized we can use a light-weight stub to enter |
257 // the runtime that is significantly faster than using the standard | 258 // the runtime that is significantly faster than using the standard |
258 // stub-failure deopt mechanism. | 259 // stub-failure deopt mechanism. |
259 if (stub->IsUninitialized() && descriptor.has_miss_handler()) { | 260 if (stub->IsUninitialized() && descriptor.has_miss_handler()) { |
260 DCHECK(!descriptor.stack_parameter_count().is_valid()); | 261 DCHECK(!descriptor.stack_parameter_count().is_valid()); |
261 return stub->GenerateLightweightMissCode(); | 262 return stub->GenerateLightweightMissCode(descriptor.miss_handler()); |
262 } | 263 } |
263 base::ElapsedTimer timer; | 264 base::ElapsedTimer timer; |
264 if (FLAG_profile_hydrogen_code_stub_compilation) { | 265 if (FLAG_profile_hydrogen_code_stub_compilation) { |
265 timer.Start(); | 266 timer.Start(); |
266 } | 267 } |
267 CodeStubGraphBuilder<Stub> builder(isolate, stub); | 268 CodeStubGraphBuilder<Stub> builder(isolate, stub); |
268 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); | 269 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); |
269 // TODO(yangguo) remove this once the code serializer handles code stubs. | 270 // TODO(yangguo) remove this once the code serializer handles code stubs. |
270 if (FLAG_serialize_toplevel) chunk->info()->PrepareForSerializing(); | 271 if (FLAG_serialize_toplevel) chunk->info()->PrepareForSerializing(); |
271 Handle<Code> code = chunk->Codegen(); | 272 Handle<Code> code = chunk->Codegen(); |
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 | 1823 |
1823 // Probe the stub cache. | 1824 // Probe the stub cache. |
1824 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( | 1825 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( |
1825 Code::ComputeHandlerFlags(Code::LOAD_IC)); | 1826 Code::ComputeHandlerFlags(Code::LOAD_IC)); |
1826 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags); | 1827 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags); |
1827 | 1828 |
1828 // We never continue. | 1829 // We never continue. |
1829 return graph()->GetConstant0(); | 1830 return graph()->GetConstant0(); |
1830 } | 1831 } |
1831 } } // namespace v8::internal | 1832 } } // namespace v8::internal |
OLD | NEW |