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

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

Issue 8640001: Implement crankshaft support for nested object literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ported lithium part to x64 and ARM. Created 9 years, 1 month 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/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('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 3908 matching lines...) Expand 10 before | Expand all | Expand 10 after
3919 FastCloneShallowArrayStub::Mode mode = 3919 FastCloneShallowArrayStub::Mode mode =
3920 constant_elements_kind == FAST_DOUBLE_ELEMENTS 3920 constant_elements_kind == FAST_DOUBLE_ELEMENTS
3921 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS 3921 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS
3922 : FastCloneShallowArrayStub::CLONE_ELEMENTS; 3922 : FastCloneShallowArrayStub::CLONE_ELEMENTS;
3923 FastCloneShallowArrayStub stub(mode, length); 3923 FastCloneShallowArrayStub stub(mode, length);
3924 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 3924 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3925 } 3925 }
3926 } 3926 }
3927 3927
3928 3928
3929 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { 3929 void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
3930 Register result,
3931 Register source,
3932 int* offset) {
3933 ASSERT(!source.is(rcx));
3934 ASSERT(!result.is(rcx));
3935
3936 // Increase the offset so that subsequent objects end up right after
3937 // this one.
3938 int current_offset = *offset;
3939 int size = object->map()->instance_size();
3940 *offset += size;
3941
3942 // Copy object header.
3943 ASSERT(object->properties()->length() == 0);
3944 ASSERT(object->elements()->length() == 0 ||
3945 object->elements()->map() == isolate()->heap()->fixed_cow_array_map());
3946 int inobject_properties = object->map()->inobject_properties();
3947 int header_size = size - inobject_properties * kPointerSize;
3948 for (int i = 0; i < header_size; i += kPointerSize) {
3949 __ movq(rcx, FieldOperand(source, i));
3950 __ movq(FieldOperand(result, current_offset + i), rcx);
3951 }
3952
3953 // Copy in-object properties.
3954 for (int i = 0; i < inobject_properties; i++) {
3955 int total_offset = current_offset + object->GetInObjectPropertyOffset(i);
3956 Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i));
3957 if (value->IsJSObject()) {
3958 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
3959 __ lea(rcx, Operand(result, *offset));
3960 __ movq(FieldOperand(result, total_offset), rcx);
3961 LoadHeapObject(source, value_object);
3962 EmitDeepCopy(value_object, result, source, offset);
3963 } else if (value->IsHeapObject()) {
3964 LoadHeapObject(rcx, Handle<HeapObject>::cast(value));
3965 __ movq(FieldOperand(result, total_offset), rcx);
3966 } else {
3967 __ movq(rcx, value, RelocInfo::NONE);
3968 __ movq(FieldOperand(result, total_offset), rcx);
3969 }
3970 }
3971 }
3972
3973
3974 void LCodeGen::DoObjectLiteralFast(LObjectLiteralFast* instr) {
3975 int size = instr->hydrogen()->total_size();
3976
3977 // Allocate all objects that are part of the literal in one big
3978 // allocation. This avoids multiple limit checks.
3979 Label allocated, runtime_allocate;
3980 __ AllocateInNewSpace(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT);
3981 __ jmp(&allocated);
3982
3983 __ bind(&runtime_allocate);
3984 __ Push(Smi::FromInt(size));
3985 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
3986
3987 __ bind(&allocated);
3988 int offset = 0;
3989 LoadHeapObject(rbx, instr->hydrogen()->boilerplate());
3990 EmitDeepCopy(instr->hydrogen()->boilerplate(), rax, rbx, &offset);
3991 ASSERT_EQ(size, offset);
3992 }
3993
3994
3995 void LCodeGen::DoObjectLiteralGeneric(LObjectLiteralGeneric* instr) {
3930 Handle<FixedArray> constant_properties = 3996 Handle<FixedArray> constant_properties =
3931 instr->hydrogen()->constant_properties(); 3997 instr->hydrogen()->constant_properties();
3932 3998
3933 // Setup the parameters to the stub/runtime call. 3999 // Setup the parameters to the stub/runtime call.
3934 __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 4000 __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
3935 __ push(FieldOperand(rax, JSFunction::kLiteralsOffset)); 4001 __ push(FieldOperand(rax, JSFunction::kLiteralsOffset));
3936 __ Push(Smi::FromInt(instr->hydrogen()->literal_index())); 4002 __ Push(Smi::FromInt(instr->hydrogen()->literal_index()));
3937 __ Push(constant_properties); 4003 __ Push(constant_properties);
3938 int flags = instr->hydrogen()->fast_elements() 4004 int flags = instr->hydrogen()->fast_elements()
3939 ? ObjectLiteral::kFastElements 4005 ? ObjectLiteral::kFastElements
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
4301 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); 4367 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
4302 ASSERT(osr_pc_offset_ == -1); 4368 ASSERT(osr_pc_offset_ == -1);
4303 osr_pc_offset_ = masm()->pc_offset(); 4369 osr_pc_offset_ = masm()->pc_offset();
4304 } 4370 }
4305 4371
4306 #undef __ 4372 #undef __
4307 4373
4308 } } // namespace v8::internal 4374 } } // namespace v8::internal
4309 4375
4310 #endif // V8_TARGET_ARCH_X64 4376 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698