Index: src/code-stubs.cc |
diff --git a/src/code-stubs.cc b/src/code-stubs.cc |
index 503f5dda0923f3836ab788c11af3afce864ccbf7..14e98beb675af2440b02b66d1ecd5181818bdade 100644 |
--- a/src/code-stubs.cc |
+++ b/src/code-stubs.cc |
@@ -4220,14 +4220,6 @@ void StringAddStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
descriptor->SetMissHandler(Runtime::kStringAdd); |
} |
- |
-void GrowArrayElementsStub::InitializeDescriptor( |
- CodeStubDescriptor* descriptor) { |
- descriptor->Initialize( |
- Runtime::FunctionForId(Runtime::kGrowArrayElements)->entry); |
-} |
- |
- |
namespace { |
compiler::Node* GenerateHasProperty( |
@@ -4997,12 +4989,42 @@ void InternalArraySingleArgumentConstructorStub::GenerateAssembly( |
DONT_TRACK_ALLOCATION_SITE); |
} |
+void GrowArrayElementsStub::GenerateAssembly( |
+ CodeStubAssembler* assembler) const { |
+ typedef compiler::Node Node; |
+ CodeStubAssembler::Label runtime(assembler, |
+ CodeStubAssembler::Label::kDeferred); |
+ |
+ Node* object = assembler->Parameter(Descriptor::kObject); |
+ Node* key = assembler->Parameter(Descriptor::kKey); |
+ Node* context = assembler->Parameter(Descriptor::kContext); |
+ ElementsKind kind = elements_kind(); |
+ |
+ Node* elements = assembler->LoadElements(object); |
+ Node* new_elements = assembler->CheckAndGrowElementsCapacity( |
+ context, elements, kind, key, &runtime); |
+ assembler->StoreObjectField(object, JSObject::kElementsOffset, new_elements); |
+ assembler->Return(new_elements); |
+ |
+ assembler->Bind(&runtime); |
+ // TODO(danno): Make this a tail call when the stub is only used from TurboFan |
+ // code. This musn't be a tail call for now, since the caller site in lithium |
+ // creates a safepoint. This safepoint musn't have a different number of |
+ // arguments on the stack in the case that a GC happens from the slow-case |
+ // allocation path (zero, since all the stubs inputs are in registers) and |
+ // when the call happens (it would be two in the tail call case due to the |
+ // tail call pushing the arguments on the stack for the runtime call). By not |
+ // tail-calling, the runtime call case also has zero arguments on the stack |
+ // for the stub frame. |
+ assembler->Return(assembler->CallRuntime(Runtime::kGrowArrayElements, context, |
+ object, key)); |
+} |
+ |
ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) |
: PlatformCodeStub(isolate) { |
minor_key_ = ArgumentCountBits::encode(ANY); |
} |
- |
ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate, |
int argument_count) |
: PlatformCodeStub(isolate) { |