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

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: 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/runtime.cc ('k') | test/cctest/test-debug.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 3818 matching lines...) Expand 10 before | Expand all | Expand 10 after
3829 } 3829 }
3830 3830
3831 // Check the holder map. 3831 // Check the holder map.
3832 __ Cmp(FieldOperand(reg, HeapObject::kMapOffset), 3832 __ Cmp(FieldOperand(reg, HeapObject::kMapOffset),
3833 Handle<Map>(current_prototype->map())); 3833 Handle<Map>(current_prototype->map()));
3834 DeoptimizeIf(not_equal, instr->environment()); 3834 DeoptimizeIf(not_equal, instr->environment());
3835 } 3835 }
3836 3836
3837 3837
3838 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { 3838 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
3839 Handle<FixedArray> constant_elements = instr->hydrogen()->constant_elements(); 3839 Heap* heap = isolate()->heap();
3840 ASSERT_EQ(2, constant_elements->length()); 3840 ElementsKind boilerplate_elements_kind =
3841 ElementsKind constant_elements_kind = 3841 instr->hydrogen()->boilerplate_elements_kind();
3842 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); 3842
3843 // Deopt if the array literal boilerplate ElementsKind is of a type different
3844 // than the expected one. The check isn't necessary if the boilerplate has
3845 // already been converted to FAST_ELEMENTS.
3846 if (boilerplate_elements_kind != FAST_ELEMENTS) {
3847 LoadHeapObject(rax, instr->hydrogen()->boilerplate_object());
3848 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
3849 // Load the map's "bit field 2".
3850 __ movb(rbx, FieldOperand(rbx, Map::kBitField2Offset));
3851 // Retrieve elements_kind from bit field 2.
3852 __ and_(rbx, Immediate(Map::kElementsKindMask));
3853 __ cmpb(rbx, Immediate(boilerplate_elements_kind <<
3854 Map::kElementsKindShift));
3855 DeoptimizeIf(not_equal, instr->environment());
3856 }
3843 3857
3844 // Setup the parameters to the stub/runtime call. 3858 // Setup the parameters to the stub/runtime call.
3845 __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 3859 __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
3846 __ push(FieldOperand(rax, JSFunction::kLiteralsOffset)); 3860 __ push(FieldOperand(rax, JSFunction::kLiteralsOffset));
3847 __ Push(Smi::FromInt(instr->hydrogen()->literal_index())); 3861 __ Push(Smi::FromInt(instr->hydrogen()->literal_index()));
3848 __ Push(instr->hydrogen()->constant_elements()); 3862 // Boilerplate already exists, constant elements are never accessed.
3863 // Pass an empty fixed array.
3864 __ Push(Handle<FixedArray>(heap->empty_fixed_array()));
3849 3865
3850 // Pick the right runtime function or stub to call. 3866 // Pick the right runtime function or stub to call.
3851 int length = instr->hydrogen()->length(); 3867 int length = instr->hydrogen()->length();
3852 if (instr->hydrogen()->IsCopyOnWrite()) { 3868 if (instr->hydrogen()->IsCopyOnWrite()) {
3853 ASSERT(instr->hydrogen()->depth() == 1); 3869 ASSERT(instr->hydrogen()->depth() == 1);
3854 FastCloneShallowArrayStub::Mode mode = 3870 FastCloneShallowArrayStub::Mode mode =
3855 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; 3871 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS;
3856 FastCloneShallowArrayStub stub(mode, length); 3872 FastCloneShallowArrayStub stub(mode, length);
3857 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 3873 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3858 } else if (instr->hydrogen()->depth() > 1) { 3874 } else if (instr->hydrogen()->depth() > 1) {
3859 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); 3875 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr);
3860 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { 3876 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
3861 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); 3877 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr);
3862 } else { 3878 } else {
3863 FastCloneShallowArrayStub::Mode mode = 3879 FastCloneShallowArrayStub::Mode mode =
3864 constant_elements_kind == FAST_DOUBLE_ELEMENTS 3880 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS
3865 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS 3881 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS
3866 : FastCloneShallowArrayStub::CLONE_ELEMENTS; 3882 : FastCloneShallowArrayStub::CLONE_ELEMENTS;
3867 FastCloneShallowArrayStub stub(mode, length); 3883 FastCloneShallowArrayStub stub(mode, length);
3868 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 3884 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3869 } 3885 }
3870 } 3886 }
3871 3887
3872 3888
3873 void LCodeGen::EmitDeepCopy(Handle<JSObject> object, 3889 void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
3874 Register result, 3890 Register result,
3875 Register source, 3891 Register source,
3876 int* offset) { 3892 int* offset) {
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
4295 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); 4311 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
4296 ASSERT(osr_pc_offset_ == -1); 4312 ASSERT(osr_pc_offset_ == -1);
4297 osr_pc_offset_ = masm()->pc_offset(); 4313 osr_pc_offset_ = masm()->pc_offset();
4298 } 4314 }
4299 4315
4300 #undef __ 4316 #undef __
4301 4317
4302 } } // namespace v8::internal 4318 } } // namespace v8::internal
4303 4319
4304 #endif // V8_TARGET_ARCH_X64 4320 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698