| Index: src/ia32/code-stubs-ia32.cc
|
| diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
|
| index bc8ac777844cc5c5bec650c9b15577bddad727e4..c3e7fe203d19fea6c2e1cd2897e12c9106d2898a 100644
|
| --- a/src/ia32/code-stubs-ia32.cc
|
| +++ b/src/ia32/code-stubs-ia32.cc
|
| @@ -323,36 +323,34 @@ static void GenerateFastCloneShallowArrayCommon(
|
| MacroAssembler* masm,
|
| int length,
|
| FastCloneShallowArrayStub::Mode mode,
|
| - AllocationSiteInfoMode allocation_site_info_mode,
|
| Label* fail) {
|
| // Registers on entry:
|
| //
|
| // ecx: boilerplate literal array.
|
| - ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS);
|
| + ASSERT(!FastCloneShallowArrayStub::IsCloneAnyElementsMode(mode));
|
| + bool tracking_on = FastCloneShallowArrayStub::TrackAllocationSiteInfo(mode);
|
|
|
| // All sizes here are multiples of kPointerSize.
|
| int elements_size = 0;
|
| if (length > 0) {
|
| - elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS
|
| + elements_size = FastCloneShallowArrayStub::IsCloneDoubleElementsMode(mode)
|
| ? FixedDoubleArray::SizeFor(length)
|
| : FixedArray::SizeFor(length);
|
| }
|
| int size = JSArray::kSize;
|
| int allocation_info_start = size;
|
| - if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) {
|
| - size += AllocationSiteInfo::kSize;
|
| - }
|
| - size += elements_size;
|
| + size += tracking_on ? AllocationSiteInfo::kSize + elements_size
|
| + : elements_size;
|
|
|
| // Allocate both the JS array and the elements array in one big
|
| // allocation. This avoids multiple limit checks.
|
| AllocationFlags flags = TAG_OBJECT;
|
| - if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) {
|
| + if (FastCloneShallowArrayStub::IsCloneDoubleElementsMode(mode)) {
|
| flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags);
|
| }
|
| __ AllocateInNewSpace(size, eax, ebx, edx, fail, flags);
|
|
|
| - if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) {
|
| + if (tracking_on) {
|
| __ mov(FieldOperand(eax, allocation_info_start),
|
| Immediate(Handle<Map>(masm->isolate()->heap()->
|
| allocation_site_info_map())));
|
| @@ -371,7 +369,7 @@ static void GenerateFastCloneShallowArrayCommon(
|
| // Get hold of the elements array of the boilerplate and setup the
|
| // elements pointer in the resulting object.
|
| __ mov(ecx, FieldOperand(ecx, JSArray::kElementsOffset));
|
| - if (allocation_site_info_mode == TRACK_ALLOCATION_SITE_INFO) {
|
| + if (tracking_on) {
|
| __ lea(edx, Operand(eax, JSArray::kSize + AllocationSiteInfo::kSize));
|
| } else {
|
| __ lea(edx, Operand(eax, JSArray::kSize));
|
| @@ -379,13 +377,13 @@ static void GenerateFastCloneShallowArrayCommon(
|
| __ mov(FieldOperand(eax, JSArray::kElementsOffset), edx);
|
|
|
| // Copy the elements array.
|
| - if (mode == FastCloneShallowArrayStub::CLONE_ELEMENTS) {
|
| + if (FastCloneShallowArrayStub::IsCloneElementsMode(mode)) {
|
| for (int i = 0; i < elements_size; i += kPointerSize) {
|
| __ mov(ebx, FieldOperand(ecx, i));
|
| __ mov(FieldOperand(edx, i), ebx);
|
| }
|
| } else {
|
| - ASSERT(mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS);
|
| + ASSERT(FastCloneShallowArrayStub::IsCloneDoubleElementsMode(mode));
|
| int i;
|
| for (i = 0; i < FixedDoubleArray::kHeaderSize; i += kPointerSize) {
|
| __ mov(ebx, FieldOperand(ecx, i));
|
| @@ -425,49 +423,42 @@ void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) {
|
|
|
| FastCloneShallowArrayStub::Mode mode = mode_;
|
| // ecx is boilerplate object.
|
| - AllocationSiteInfoMode allocation_site_info_mode =
|
| - DONT_TRACK_ALLOCATION_SITE_INFO;
|
| - if (mode == CLONE_ANY_ELEMENTS_WITH_ALLOCATION_SITE_INFO) {
|
| - mode = CLONE_ANY_ELEMENTS;
|
| - allocation_site_info_mode = TRACK_ALLOCATION_SITE_INFO;
|
| - }
|
| -
|
| - if (mode == CLONE_ANY_ELEMENTS) {
|
| + if (FastCloneShallowArrayStub::IsCloneAnyElementsMode(mode)) {
|
| Label double_elements, check_fast_elements;
|
| __ mov(ebx, FieldOperand(ecx, JSArray::kElementsOffset));
|
| __ CheckMap(ebx, factory->fixed_cow_array_map(),
|
| &check_fast_elements, DONT_DO_SMI_CHECK);
|
| - GenerateFastCloneShallowArrayCommon(masm, 0,
|
| - COPY_ON_WRITE_ELEMENTS,
|
| - allocation_site_info_mode,
|
| - &slow_case);
|
| + bool tracking_on = FastCloneShallowArrayStub::TrackAllocationSiteInfo(mode);
|
| + mode = tracking_on ? COPY_ON_WRITE_ELEMENTS_WITH_ALLOCATION_SITE_INFO
|
| + : COPY_ON_WRITE_ELEMENTS;
|
| + GenerateFastCloneShallowArrayCommon(masm, 0, mode, &slow_case);
|
| __ ret(3 * kPointerSize);
|
|
|
| __ bind(&check_fast_elements);
|
| __ CheckMap(ebx, factory->fixed_array_map(),
|
| &double_elements, DONT_DO_SMI_CHECK);
|
| - GenerateFastCloneShallowArrayCommon(masm, length_,
|
| - CLONE_ELEMENTS,
|
| - allocation_site_info_mode,
|
| - &slow_case);
|
| + mode = tracking_on ? CLONE_ELEMENTS_WITH_ALLOCATION_SITE_INFO
|
| + : CLONE_ELEMENTS;
|
| + GenerateFastCloneShallowArrayCommon(masm, length_, mode, &slow_case);
|
| __ ret(3 * kPointerSize);
|
|
|
| __ bind(&double_elements);
|
| - mode = CLONE_DOUBLE_ELEMENTS;
|
| + mode = tracking_on ? CLONE_DOUBLE_ELEMENTS_WITH_ALLOCATION_SITE_INFO
|
| + : CLONE_DOUBLE_ELEMENTS;
|
| // Fall through to generate the code to handle double elements.
|
| }
|
|
|
| if (FLAG_debug_code) {
|
| const char* message;
|
| Handle<Map> expected_map;
|
| - if (mode == CLONE_ELEMENTS) {
|
| + if (FastCloneShallowArrayStub::IsCloneElementsMode(mode)) {
|
| message = "Expected (writable) fixed array";
|
| expected_map = factory->fixed_array_map();
|
| - } else if (mode == CLONE_DOUBLE_ELEMENTS) {
|
| + } else if (FastCloneShallowArrayStub::IsCloneDoubleElementsMode(mode)) {
|
| message = "Expected (writable) fixed double array";
|
| expected_map = factory->fixed_double_array_map();
|
| } else {
|
| - ASSERT(mode == COPY_ON_WRITE_ELEMENTS);
|
| + ASSERT(FastCloneShallowArrayStub::IsCopyOnWriteElementsMode(mode));
|
| message = "Expected copy-on-write fixed array";
|
| expected_map = factory->fixed_cow_array_map();
|
| }
|
| @@ -478,8 +469,8 @@ void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) {
|
| __ pop(ecx);
|
| }
|
|
|
| - GenerateFastCloneShallowArrayCommon(masm, length_, mode,
|
| - allocation_site_info_mode, &slow_case);
|
| + GenerateFastCloneShallowArrayCommon(masm, length_, mode, &slow_case);
|
| +
|
| // Return and remove the on-stack parameters.
|
| __ ret(3 * kPointerSize);
|
|
|
|
|