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 <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 4171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4182 const { | 4182 const { |
4183 return VectorStoreTransitionDescriptor(isolate()); | 4183 return VectorStoreTransitionDescriptor(isolate()); |
4184 } | 4184 } |
4185 | 4185 |
4186 | 4186 |
4187 CallInterfaceDescriptor | 4187 CallInterfaceDescriptor |
4188 ElementsTransitionAndStoreStub::GetCallInterfaceDescriptor() const { | 4188 ElementsTransitionAndStoreStub::GetCallInterfaceDescriptor() const { |
4189 return VectorStoreTransitionDescriptor(isolate()); | 4189 return VectorStoreTransitionDescriptor(isolate()); |
4190 } | 4190 } |
4191 | 4191 |
4192 void FastNewClosureStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {} | |
4193 | |
4194 void FastNewContextStub::InitializeDescriptor(CodeStubDescriptor* d) {} | 4192 void FastNewContextStub::InitializeDescriptor(CodeStubDescriptor* d) {} |
4195 | 4193 |
4196 | |
4197 void TypeofStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {} | 4194 void TypeofStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {} |
4198 | 4195 |
4199 | |
4200 void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4196 void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
4201 descriptor->Initialize( | 4197 descriptor->Initialize( |
4202 Runtime::FunctionForId(Runtime::kNumberToString)->entry); | 4198 Runtime::FunctionForId(Runtime::kNumberToString)->entry); |
4203 } | 4199 } |
4204 | 4200 |
4205 | 4201 |
4206 void FastCloneRegExpStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4202 void FastCloneRegExpStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
4207 FastCloneRegExpDescriptor call_descriptor(isolate()); | 4203 FastCloneRegExpDescriptor call_descriptor(isolate()); |
4208 descriptor->Initialize( | 4204 descriptor->Initialize( |
4209 Runtime::FunctionForId(Runtime::kCreateRegExpLiteral)->entry); | 4205 Runtime::FunctionForId(Runtime::kCreateRegExpLiteral)->entry); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4418 { | 4414 { |
4419 result.Bind( | 4415 result.Bind( |
4420 assembler->CallRuntime(Runtime::kHasProperty, context, key, object)); | 4416 assembler->CallRuntime(Runtime::kHasProperty, context, key, object)); |
4421 assembler->Goto(&end); | 4417 assembler->Goto(&end); |
4422 } | 4418 } |
4423 | 4419 |
4424 assembler->Bind(&end); | 4420 assembler->Bind(&end); |
4425 return result.value(); | 4421 return result.value(); |
4426 } | 4422 } |
4427 | 4423 |
| 4424 // static |
| 4425 compiler::Node* FastNewClosureStub::Generate(CodeStubAssembler* assembler, |
| 4426 compiler::Node* shared_info, |
| 4427 compiler::Node* context, |
| 4428 compiler::Node* map_index) { |
| 4429 typedef compiler::Node Node; |
| 4430 |
| 4431 Isolate* isolate = assembler->isolate(); |
| 4432 Factory* factory = assembler->isolate()->factory(); |
| 4433 assembler->IncrementCounter(isolate->counters()->fast_new_closure_total(), 1); |
| 4434 |
| 4435 // Create a new closure from the given function info in new space |
| 4436 Node* result = assembler->Allocate(JSFunction::kSize); |
| 4437 |
| 4438 // Get the function map in the current native context and set that |
| 4439 // as the map of the allocated object. |
| 4440 Node* native_context = assembler->LoadNativeContext(context); |
| 4441 Node* map_slot_value = |
| 4442 assembler->LoadFixedArrayElement(native_context, map_index); |
| 4443 assembler->StoreMapNoWriteBarrier(result, map_slot_value); |
| 4444 |
| 4445 // Initialize the rest of the function. |
| 4446 Node* empty_fixed_array = |
| 4447 assembler->HeapConstant(factory->empty_fixed_array()); |
| 4448 Node* empty_literals_array = |
| 4449 assembler->HeapConstant(factory->empty_literals_array()); |
| 4450 assembler->StoreObjectFieldNoWriteBarrier(result, JSObject::kPropertiesOffset, |
| 4451 empty_fixed_array); |
| 4452 assembler->StoreObjectFieldNoWriteBarrier(result, JSObject::kElementsOffset, |
| 4453 empty_fixed_array); |
| 4454 assembler->StoreObjectFieldNoWriteBarrier(result, JSFunction::kLiteralsOffset, |
| 4455 empty_literals_array); |
| 4456 assembler->StoreObjectFieldNoWriteBarrier( |
| 4457 result, JSFunction::kPrototypeOrInitialMapOffset, |
| 4458 assembler->TheHoleConstant()); |
| 4459 assembler->StoreObjectFieldNoWriteBarrier( |
| 4460 result, JSFunction::kSharedFunctionInfoOffset, shared_info); |
| 4461 assembler->StoreObjectFieldNoWriteBarrier(result, JSFunction::kContextOffset, |
| 4462 context); |
| 4463 |
| 4464 // TODO(rmcilroy): Should we set the code entry from the SharedFunctionInfo |
| 4465 // instead? For eager compilation this would seem preferable. |
| 4466 Handle<Code> lazy_builtin_handle( |
| 4467 assembler->isolate()->builtins()->builtin(Builtins::kCompileLazy)); |
| 4468 Node* lazy_builtin = assembler->HeapConstant(lazy_builtin_handle); |
| 4469 Node* lazy_builtin_entry = assembler->IntPtrAdd( |
| 4470 lazy_builtin, |
| 4471 assembler->IntPtrConstant(Code::kHeaderSize - kHeapObjectTag)); |
| 4472 assembler->StoreObjectFieldNoWriteBarrier( |
| 4473 result, JSFunction::kCodeEntryOffset, lazy_builtin_entry); |
| 4474 assembler->StoreObjectFieldNoWriteBarrier(result, |
| 4475 JSFunction::kNextFunctionLinkOffset, |
| 4476 assembler->UndefinedConstant()); |
| 4477 |
| 4478 return result; |
| 4479 } |
| 4480 |
| 4481 void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const { |
| 4482 int map_index = Context::FunctionMapIndex(language_mode(), kind()); |
| 4483 assembler->Return(Generate(assembler, assembler->Parameter(0), |
| 4484 assembler->Parameter(1), |
| 4485 assembler->Int32Constant(map_index))); |
| 4486 } |
| 4487 |
4428 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { | 4488 void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { |
4429 CreateAllocationSiteStub stub(isolate); | 4489 CreateAllocationSiteStub stub(isolate); |
4430 stub.GetCode(); | 4490 stub.GetCode(); |
4431 } | 4491 } |
4432 | 4492 |
4433 | 4493 |
4434 void CreateWeakCellStub::GenerateAheadOfTime(Isolate* isolate) { | 4494 void CreateWeakCellStub::GenerateAheadOfTime(Isolate* isolate) { |
4435 CreateWeakCellStub stub(isolate); | 4495 CreateWeakCellStub stub(isolate); |
4436 stub.GetCode(); | 4496 stub.GetCode(); |
4437 } | 4497 } |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4730 if (type->Is(Type::UntaggedPointer())) { | 4790 if (type->Is(Type::UntaggedPointer())) { |
4731 return Representation::External(); | 4791 return Representation::External(); |
4732 } | 4792 } |
4733 | 4793 |
4734 DCHECK(!type->Is(Type::Untagged())); | 4794 DCHECK(!type->Is(Type::Untagged())); |
4735 return Representation::Tagged(); | 4795 return Representation::Tagged(); |
4736 } | 4796 } |
4737 | 4797 |
4738 } // namespace internal | 4798 } // namespace internal |
4739 } // namespace v8 | 4799 } // namespace v8 |
OLD | NEW |