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

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

Issue 8747009: Optimize Crankshaft array literal initialization from boilerplate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix stuff 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
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 3815 matching lines...) Expand 10 before | Expand all | Expand 10 after
3826 } 3826 }
3827 3827
3828 // Check the holder map. 3828 // Check the holder map.
3829 __ Cmp(FieldOperand(reg, HeapObject::kMapOffset), 3829 __ Cmp(FieldOperand(reg, HeapObject::kMapOffset),
3830 Handle<Map>(current_prototype->map())); 3830 Handle<Map>(current_prototype->map()));
3831 DeoptimizeIf(not_equal, instr->environment()); 3831 DeoptimizeIf(not_equal, instr->environment());
3832 } 3832 }
3833 3833
3834 3834
3835 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { 3835 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
3836 Handle<FixedArray> constant_elements = instr->hydrogen()->constant_elements(); 3836 Heap* heap = isolate()->heap();
3837 ASSERT_EQ(2, constant_elements->length()); 3837 ElementsKind boilerplate_elements_kind =
3838 ElementsKind constant_elements_kind = 3838 instr->hydrogen()->boilerplate_elements_kind();
3839 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); 3839
3840 // Deopt if the array literal boilerplate ElementsKind is of a type different
3841 // than the expected one. The check isn't necessary if the boilerplate has
3842 // already been converted to FAST_ELEMENTS.
3843 if (boilerplate_elements_kind != FAST_ELEMENTS) {
3844 LoadHeapObject(rax, instr->hydrogen()->boilerplate_object());
3845 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
3846 // Load the map's "bit field 2".
3847 __ movb(rbx, FieldOperand(rbx, Map::kBitField2Offset));
3848 // Retrieve elements_kind from bit field 2.
3849 __ and_(rbx, Immediate(Map::kElementsKindMask));
3850 __ cmpb(rbx, Immediate(boilerplate_elements_kind <<
3851 Map::kElementsKindShift));
3852 DeoptimizeIf(not_equal, instr->environment());
3853 }
3840 3854
3841 // Setup the parameters to the stub/runtime call. 3855 // Setup the parameters to the stub/runtime call.
3842 __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 3856 __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
3843 __ push(FieldOperand(rax, JSFunction::kLiteralsOffset)); 3857 __ push(FieldOperand(rax, JSFunction::kLiteralsOffset));
3844 __ Push(Smi::FromInt(instr->hydrogen()->literal_index())); 3858 __ Push(Smi::FromInt(instr->hydrogen()->literal_index()));
3845 __ Push(instr->hydrogen()->constant_elements()); 3859 // Boilerplate already exists, constant elements are never accessed.
3860 // Pass an empty fixed array.
3861 __ Push(Handle<FixedArray>(heap->empty_fixed_array()));
3846 3862
3847 // Pick the right runtime function or stub to call. 3863 // Pick the right runtime function or stub to call.
3848 int length = instr->hydrogen()->length(); 3864 int length = instr->hydrogen()->length();
3849 if (instr->hydrogen()->IsCopyOnWrite()) { 3865 if (instr->hydrogen()->IsCopyOnWrite()) {
3850 ASSERT(instr->hydrogen()->depth() == 1); 3866 ASSERT(instr->hydrogen()->depth() == 1);
3851 FastCloneShallowArrayStub::Mode mode = 3867 FastCloneShallowArrayStub::Mode mode =
3852 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; 3868 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS;
3853 FastCloneShallowArrayStub stub(mode, length); 3869 FastCloneShallowArrayStub stub(mode, length);
3854 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 3870 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3855 } else if (instr->hydrogen()->depth() > 1) { 3871 } else if (instr->hydrogen()->depth() > 1) {
3856 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); 3872 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr);
3857 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { 3873 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
3858 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); 3874 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr);
3859 } else { 3875 } else {
3860 FastCloneShallowArrayStub::Mode mode = 3876 FastCloneShallowArrayStub::Mode mode =
3861 constant_elements_kind == FAST_DOUBLE_ELEMENTS 3877 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS
3862 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS 3878 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS
3863 : FastCloneShallowArrayStub::CLONE_ELEMENTS; 3879 : FastCloneShallowArrayStub::CLONE_ELEMENTS;
3864 FastCloneShallowArrayStub stub(mode, length); 3880 FastCloneShallowArrayStub stub(mode, length);
3865 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 3881 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3866 } 3882 }
3867 } 3883 }
3868 3884
3869 3885
3870 void LCodeGen::EmitDeepCopy(Handle<JSObject> object, 3886 void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
3871 Register result, 3887 Register result,
3872 Register source, 3888 Register source,
3873 int* offset) { 3889 int* offset) {
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
4308 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); 4324 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
4309 ASSERT(osr_pc_offset_ == -1); 4325 ASSERT(osr_pc_offset_ == -1);
4310 osr_pc_offset_ = masm()->pc_offset(); 4326 osr_pc_offset_ = masm()->pc_offset();
4311 } 4327 }
4312 4328
4313 #undef __ 4329 #undef __
4314 4330
4315 } } // namespace v8::internal 4331 } } // namespace v8::internal
4316 4332
4317 #endif // V8_TARGET_ARCH_X64 4333 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698