Chromium Code Reviews| Index: src/code-stubs.cc |
| diff --git a/src/code-stubs.cc b/src/code-stubs.cc |
| index 503f5dda0923f3836ab788c11af3afce864ccbf7..0baadafc65c323ee1e7524c0ede2e6182671df67 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,47 @@ 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* current_capacity = assembler->LoadFixedArrayBaseLength(elements); |
| + |
| + Node* new_elements = assembler->CheckAndGrowElementsCapacity( |
| + context, object, elements, kind, current_capacity, 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 |
|
Benedikt Meurer
2016/08/05 04:35:21
Ouch!
|
| + // 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) { |