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/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/crankshaft/hydrogen.h" | 10 #include "src/crankshaft/hydrogen.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 // Create the code object. | 241 // Create the code object. |
242 CodeDesc desc; | 242 CodeDesc desc; |
243 masm.GetCode(&desc); | 243 masm.GetCode(&desc); |
244 | 244 |
245 // Copy the generated code into a heap object. | 245 // Copy the generated code into a heap object. |
246 Handle<Code> new_object = factory->NewCode( | 246 Handle<Code> new_object = factory->NewCode( |
247 desc, GetCodeFlags(), masm.CodeObject(), NeedsImmovableCode()); | 247 desc, GetCodeFlags(), masm.CodeObject(), NeedsImmovableCode()); |
248 return new_object; | 248 return new_object; |
249 } | 249 } |
250 | 250 |
| 251 Handle<Code> HydrogenCodeStub::GenerateRuntimeTailCall( |
| 252 CodeStubDescriptor* descriptor) { |
| 253 const char* name = CodeStub::MajorName(MajorKey()); |
| 254 Zone zone(isolate()->allocator()); |
| 255 CallInterfaceDescriptor interface_descriptor(GetCallInterfaceDescriptor()); |
| 256 CodeStubAssembler assembler(isolate(), &zone, interface_descriptor, |
| 257 GetCodeFlags(), name); |
| 258 int total_params = interface_descriptor.GetStackParameterCount() + |
| 259 interface_descriptor.GetRegisterParameterCount(); |
| 260 switch (total_params) { |
| 261 case 0: |
| 262 assembler.TailCallRuntime(descriptor->miss_handler_id(), |
| 263 assembler.Parameter(0)); |
| 264 break; |
| 265 case 1: |
| 266 assembler.TailCallRuntime(descriptor->miss_handler_id(), |
| 267 assembler.Parameter(1), assembler.Parameter(0)); |
| 268 break; |
| 269 case 2: |
| 270 assembler.TailCallRuntime(descriptor->miss_handler_id(), |
| 271 assembler.Parameter(2), assembler.Parameter(0), |
| 272 assembler.Parameter(1)); |
| 273 break; |
| 274 case 3: |
| 275 assembler.TailCallRuntime(descriptor->miss_handler_id(), |
| 276 assembler.Parameter(3), assembler.Parameter(0), |
| 277 assembler.Parameter(1), assembler.Parameter(2)); |
| 278 break; |
| 279 case 4: |
| 280 assembler.TailCallRuntime(descriptor->miss_handler_id(), |
| 281 assembler.Parameter(4), assembler.Parameter(0), |
| 282 assembler.Parameter(1), assembler.Parameter(2), |
| 283 assembler.Parameter(3)); |
| 284 break; |
| 285 default: |
| 286 UNIMPLEMENTED(); |
| 287 break; |
| 288 } |
| 289 return assembler.GenerateCode(); |
| 290 } |
251 | 291 |
252 template <class Stub> | 292 template <class Stub> |
253 static Handle<Code> DoGenerateCode(Stub* stub) { | 293 static Handle<Code> DoGenerateCode(Stub* stub) { |
254 Isolate* isolate = stub->isolate(); | 294 Isolate* isolate = stub->isolate(); |
255 CodeStubDescriptor descriptor(stub); | 295 CodeStubDescriptor descriptor(stub); |
256 | 296 |
| 297 if (FLAG_minimal && descriptor.has_miss_handler()) { |
| 298 return stub->GenerateRuntimeTailCall(&descriptor); |
| 299 } |
| 300 |
257 // If we are uninitialized we can use a light-weight stub to enter | 301 // If we are uninitialized we can use a light-weight stub to enter |
258 // the runtime that is significantly faster than using the standard | 302 // the runtime that is significantly faster than using the standard |
259 // stub-failure deopt mechanism. | 303 // stub-failure deopt mechanism. |
260 if (stub->IsUninitialized() && descriptor.has_miss_handler()) { | 304 if (stub->IsUninitialized() && descriptor.has_miss_handler()) { |
261 DCHECK(!descriptor.stack_parameter_count().is_valid()); | 305 DCHECK(!descriptor.stack_parameter_count().is_valid()); |
262 return stub->GenerateLightweightMissCode(descriptor.miss_handler()); | 306 return stub->GenerateLightweightMissCode(descriptor.miss_handler()); |
263 } | 307 } |
264 base::ElapsedTimer timer; | 308 base::ElapsedTimer timer; |
265 if (FLAG_profile_hydrogen_code_stub_compilation) { | 309 if (FLAG_profile_hydrogen_code_stub_compilation) { |
266 timer.Start(); | 310 timer.Start(); |
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2103 return Pop(); | 2147 return Pop(); |
2104 } | 2148 } |
2105 | 2149 |
2106 | 2150 |
2107 Handle<Code> KeyedLoadGenericStub::GenerateCode() { | 2151 Handle<Code> KeyedLoadGenericStub::GenerateCode() { |
2108 return DoGenerateCode(this); | 2152 return DoGenerateCode(this); |
2109 } | 2153 } |
2110 | 2154 |
2111 } // namespace internal | 2155 } // namespace internal |
2112 } // namespace v8 | 2156 } // namespace v8 |
OLD | NEW |