Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

Issue 8747009: Optimize Crankshaft array literal initialization from boilerplate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: merge with latest Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4118 matching lines...) Expand 10 before | Expand all | Expand 10 after
4129 4129
4130 // Check the holder map. 4130 // Check the holder map.
4131 __ cmp(FieldOperand(reg, HeapObject::kMapOffset), 4131 __ cmp(FieldOperand(reg, HeapObject::kMapOffset),
4132 Handle<Map>(current_prototype->map())); 4132 Handle<Map>(current_prototype->map()));
4133 DeoptimizeIf(not_equal, instr->environment()); 4133 DeoptimizeIf(not_equal, instr->environment());
4134 } 4134 }
4135 4135
4136 4136
4137 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { 4137 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
4138 ASSERT(ToRegister(instr->context()).is(esi)); 4138 ASSERT(ToRegister(instr->context()).is(esi));
4139 Heap* heap = isolate()->heap();
4140 ElementsKind boilerplate_elements_kind =
4141 instr->hydrogen()->boilerplate_elements_kind();
4139 4142
4140 Handle<FixedArray> constant_elements = instr->hydrogen()->constant_elements(); 4143 // Deopt if the array literal boilerplate ElementsKind is of a type different
4141 ASSERT_EQ(2, constant_elements->length()); 4144 // than the expected one. The check isn't necessary if the boilerplate has
4142 ElementsKind constant_elements_kind = 4145 // already been converted to FAST_ELEMENTS.
4143 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); 4146 if (boilerplate_elements_kind != FAST_ELEMENTS) {
4147 LoadHeapObject(eax, instr->hydrogen()->boilerplate_object());
4148 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
4149 // Load the map's "bit field 2". We only need the first byte,
4150 // but the following masking takes care of that anyway.
4151 __ mov(ebx, FieldOperand(ebx, Map::kBitField2Offset));
4152 // Retrieve elements_kind from bit field 2.
4153 __ and_(ebx, Map::kElementsKindMask);
4154 __ cmp(ebx, boilerplate_elements_kind << Map::kElementsKindShift);
4155 DeoptimizeIf(not_equal, instr->environment());
4156 }
4144 4157
4145 // Setup the parameters to the stub/runtime call. 4158 // Setup the parameters to the stub/runtime call.
4146 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 4159 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
4147 __ push(FieldOperand(eax, JSFunction::kLiteralsOffset)); 4160 __ push(FieldOperand(eax, JSFunction::kLiteralsOffset));
4148 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); 4161 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index())));
4149 __ push(Immediate(constant_elements)); 4162 // Boilerplate already exists, constant elements are never accessed.
4163 // Pass an empty fixed array.
4164 __ push(Immediate(Handle<FixedArray>(heap->empty_fixed_array())));
4150 4165
4151 // Pick the right runtime function or stub to call. 4166 // Pick the right runtime function or stub to call.
4152 int length = instr->hydrogen()->length(); 4167 int length = instr->hydrogen()->length();
4153 if (instr->hydrogen()->IsCopyOnWrite()) { 4168 if (instr->hydrogen()->IsCopyOnWrite()) {
4154 ASSERT(instr->hydrogen()->depth() == 1); 4169 ASSERT(instr->hydrogen()->depth() == 1);
4155 FastCloneShallowArrayStub::Mode mode = 4170 FastCloneShallowArrayStub::Mode mode =
4156 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; 4171 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS;
4157 FastCloneShallowArrayStub stub(mode, length); 4172 FastCloneShallowArrayStub stub(mode, length);
4158 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 4173 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
4159 } else if (instr->hydrogen()->depth() > 1) { 4174 } else if (instr->hydrogen()->depth() > 1) {
4160 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); 4175 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr);
4161 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { 4176 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
4162 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); 4177 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr);
4163 } else { 4178 } else {
4164 FastCloneShallowArrayStub::Mode mode = 4179 FastCloneShallowArrayStub::Mode mode =
4165 constant_elements_kind == FAST_DOUBLE_ELEMENTS 4180 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS
4166 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS 4181 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS
4167 : FastCloneShallowArrayStub::CLONE_ELEMENTS; 4182 : FastCloneShallowArrayStub::CLONE_ELEMENTS;
4168 FastCloneShallowArrayStub stub(mode, length); 4183 FastCloneShallowArrayStub stub(mode, length);
4169 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 4184 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
4170 } 4185 }
4171 } 4186 }
4172 4187
4173 4188
4174 void LCodeGen::EmitDeepCopy(Handle<JSObject> object, 4189 void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
4175 Register result, 4190 Register result,
4176 Register source, 4191 Register source,
4177 int* offset) { 4192 int* offset) {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
4611 this, pointers, Safepoint::kLazyDeopt); 4626 this, pointers, Safepoint::kLazyDeopt);
4612 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4627 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4613 } 4628 }
4614 4629
4615 4630
4616 #undef __ 4631 #undef __
4617 4632
4618 } } // namespace v8::internal 4633 } } // namespace v8::internal
4619 4634
4620 #endif // V8_TARGET_ARCH_IA32 4635 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698