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 4202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4213 descriptor->Initialize( | 4213 descriptor->Initialize( |
4214 FUNCTION_ADDR(Runtime_BinaryOpIC_MissWithAllocationSite)); | 4214 FUNCTION_ADDR(Runtime_BinaryOpIC_MissWithAllocationSite)); |
4215 } | 4215 } |
4216 | 4216 |
4217 | 4217 |
4218 void StringAddStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 4218 void StringAddStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
4219 descriptor->Initialize(Runtime::FunctionForId(Runtime::kStringAdd)->entry); | 4219 descriptor->Initialize(Runtime::FunctionForId(Runtime::kStringAdd)->entry); |
4220 descriptor->SetMissHandler(Runtime::kStringAdd); | 4220 descriptor->SetMissHandler(Runtime::kStringAdd); |
4221 } | 4221 } |
4222 | 4222 |
4223 | |
4224 void GrowArrayElementsStub::InitializeDescriptor( | |
4225 CodeStubDescriptor* descriptor) { | |
4226 descriptor->Initialize( | |
4227 Runtime::FunctionForId(Runtime::kGrowArrayElements)->entry); | |
4228 } | |
4229 | |
4230 | |
4231 namespace { | 4223 namespace { |
4232 | 4224 |
4233 compiler::Node* GenerateHasProperty( | 4225 compiler::Node* GenerateHasProperty( |
4234 CodeStubAssembler* assembler, compiler::Node* object, compiler::Node* key, | 4226 CodeStubAssembler* assembler, compiler::Node* object, compiler::Node* key, |
4235 compiler::Node* context, Runtime::FunctionId fallback_runtime_function_id) { | 4227 compiler::Node* context, Runtime::FunctionId fallback_runtime_function_id) { |
4236 typedef compiler::Node Node; | 4228 typedef compiler::Node Node; |
4237 typedef CodeStubAssembler::Label Label; | 4229 typedef CodeStubAssembler::Label Label; |
4238 typedef CodeStubAssembler::Variable Variable; | 4230 typedef CodeStubAssembler::Variable Variable; |
4239 | 4231 |
4240 Label call_runtime(assembler, Label::kDeferred), return_true(assembler), | 4232 Label call_runtime(assembler, Label::kDeferred), return_true(assembler), |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4990 CodeStubAssembler* assembler) const { | 4982 CodeStubAssembler* assembler) const { |
4991 typedef compiler::Node Node; | 4983 typedef compiler::Node Node; |
4992 Node* function = assembler->Parameter(Descriptor::kFunction); | 4984 Node* function = assembler->Parameter(Descriptor::kFunction); |
4993 Node* array_map = assembler->LoadObjectField( | 4985 Node* array_map = assembler->LoadObjectField( |
4994 function, JSFunction::kPrototypeOrInitialMapOffset); | 4986 function, JSFunction::kPrototypeOrInitialMapOffset); |
4995 SingleArgumentConstructorCommon<Descriptor>( | 4987 SingleArgumentConstructorCommon<Descriptor>( |
4996 assembler, elements_kind(), array_map, assembler->UndefinedConstant(), | 4988 assembler, elements_kind(), array_map, assembler->UndefinedConstant(), |
4997 DONT_TRACK_ALLOCATION_SITE); | 4989 DONT_TRACK_ALLOCATION_SITE); |
4998 } | 4990 } |
4999 | 4991 |
| 4992 void GrowArrayElementsStub::GenerateAssembly( |
| 4993 CodeStubAssembler* assembler) const { |
| 4994 typedef compiler::Node Node; |
| 4995 CodeStubAssembler::Label runtime(assembler, |
| 4996 CodeStubAssembler::Label::kDeferred); |
| 4997 |
| 4998 Node* object = assembler->Parameter(Descriptor::kObject); |
| 4999 Node* key = assembler->Parameter(Descriptor::kKey); |
| 5000 Node* context = assembler->Parameter(Descriptor::kContext); |
| 5001 ElementsKind kind = elements_kind(); |
| 5002 |
| 5003 Node* elements = assembler->LoadElements(object); |
| 5004 Node* new_elements = assembler->CheckAndGrowElementsCapacity( |
| 5005 context, elements, kind, key, &runtime); |
| 5006 assembler->StoreObjectField(object, JSObject::kElementsOffset, new_elements); |
| 5007 assembler->Return(new_elements); |
| 5008 |
| 5009 assembler->Bind(&runtime); |
| 5010 // TODO(danno): Make this a tail call when the stub is only used from TurboFan |
| 5011 // code. This musn't be a tail call for now, since the caller site in lithium |
| 5012 // creates a safepoint. This safepoint musn't have a different number of |
| 5013 // arguments on the stack in the case that a GC happens from the slow-case |
| 5014 // allocation path (zero, since all the stubs inputs are in registers) and |
| 5015 // when the call happens (it would be two in the tail call case due to the |
| 5016 // tail call pushing the arguments on the stack for the runtime call). By not |
| 5017 // tail-calling, the runtime call case also has zero arguments on the stack |
| 5018 // for the stub frame. |
| 5019 assembler->Return(assembler->CallRuntime(Runtime::kGrowArrayElements, context, |
| 5020 object, key)); |
| 5021 } |
| 5022 |
5000 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) | 5023 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) |
5001 : PlatformCodeStub(isolate) { | 5024 : PlatformCodeStub(isolate) { |
5002 minor_key_ = ArgumentCountBits::encode(ANY); | 5025 minor_key_ = ArgumentCountBits::encode(ANY); |
5003 } | 5026 } |
5004 | 5027 |
5005 | |
5006 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate, | 5028 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate, |
5007 int argument_count) | 5029 int argument_count) |
5008 : PlatformCodeStub(isolate) { | 5030 : PlatformCodeStub(isolate) { |
5009 if (argument_count == 0) { | 5031 if (argument_count == 0) { |
5010 minor_key_ = ArgumentCountBits::encode(NONE); | 5032 minor_key_ = ArgumentCountBits::encode(NONE); |
5011 } else if (argument_count == 1) { | 5033 } else if (argument_count == 1) { |
5012 minor_key_ = ArgumentCountBits::encode(ONE); | 5034 minor_key_ = ArgumentCountBits::encode(ONE); |
5013 } else if (argument_count >= 2) { | 5035 } else if (argument_count >= 2) { |
5014 minor_key_ = ArgumentCountBits::encode(MORE_THAN_ONE); | 5036 minor_key_ = ArgumentCountBits::encode(MORE_THAN_ONE); |
5015 } else { | 5037 } else { |
(...skipping 16 matching lines...) Expand all Loading... |
5032 if (type->Is(Type::UntaggedPointer())) { | 5054 if (type->Is(Type::UntaggedPointer())) { |
5033 return Representation::External(); | 5055 return Representation::External(); |
5034 } | 5056 } |
5035 | 5057 |
5036 DCHECK(!type->Is(Type::Untagged())); | 5058 DCHECK(!type->Is(Type::Untagged())); |
5037 return Representation::Tagged(); | 5059 return Representation::Tagged(); |
5038 } | 5060 } |
5039 | 5061 |
5040 } // namespace internal | 5062 } // namespace internal |
5041 } // namespace v8 | 5063 } // namespace v8 |
OLD | NEW |