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

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

Issue 8883049: Merge patches to 3.7 to make MIPS work. (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.7/
Patch Set: 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/mips/lithium-codegen-mips.h ('k') | src/mips/lithium-mips.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 3502 matching lines...) Expand 10 before | Expand all | Expand 10 after
3513 class DeferredStringCharCodeAt: public LDeferredCode { 3513 class DeferredStringCharCodeAt: public LDeferredCode {
3514 public: 3514 public:
3515 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) 3515 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr)
3516 : LDeferredCode(codegen), instr_(instr) { } 3516 : LDeferredCode(codegen), instr_(instr) { }
3517 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } 3517 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); }
3518 virtual LInstruction* instr() { return instr_; } 3518 virtual LInstruction* instr() { return instr_; }
3519 private: 3519 private:
3520 LStringCharCodeAt* instr_; 3520 LStringCharCodeAt* instr_;
3521 }; 3521 };
3522 3522
3523 Register temp = scratch1();
3524 Register string = ToRegister(instr->string());
3525 Register index = ToRegister(instr->index());
3526 Register result = ToRegister(instr->result());
3527 DeferredStringCharCodeAt* deferred = 3523 DeferredStringCharCodeAt* deferred =
3528 new DeferredStringCharCodeAt(this, instr); 3524 new DeferredStringCharCodeAt(this, instr);
3529 3525 StringCharLoadGenerator::Generate(masm(),
3530 // Fetch the instance type of the receiver into result register. 3526 ToRegister(instr->string()),
3531 __ lw(result, FieldMemOperand(string, HeapObject::kMapOffset)); 3527 ToRegister(instr->index()),
3532 __ lbu(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); 3528 ToRegister(instr->result()),
3533 3529 deferred->entry());
3534 // We need special handling for indirect strings.
3535 Label check_sequential;
3536 __ And(temp, result, kIsIndirectStringMask);
3537 __ Branch(&check_sequential, eq, temp, Operand(zero_reg));
3538
3539 // Dispatch on the indirect string shape: slice or cons.
3540 Label cons_string;
3541 __ And(temp, result, kSlicedNotConsMask);
3542 __ Branch(&cons_string, eq, temp, Operand(zero_reg));
3543
3544 // Handle slices.
3545 Label indirect_string_loaded;
3546 __ lw(result, FieldMemOperand(string, SlicedString::kOffsetOffset));
3547 __ sra(temp, result, kSmiTagSize);
3548 __ addu(index, index, temp);
3549 __ lw(string, FieldMemOperand(string, SlicedString::kParentOffset));
3550 __ jmp(&indirect_string_loaded);
3551
3552 // Handle conses.
3553 // Check whether the right hand side is the empty string (i.e. if
3554 // this is really a flat string in a cons string). If that is not
3555 // the case we would rather go to the runtime system now to flatten
3556 // the string.
3557 __ bind(&cons_string);
3558 __ lw(result, FieldMemOperand(string, ConsString::kSecondOffset));
3559 __ LoadRoot(temp, Heap::kEmptyStringRootIndex);
3560 __ Branch(deferred->entry(), ne, result, Operand(temp));
3561 // Get the first of the two strings and load its instance type.
3562 __ lw(string, FieldMemOperand(string, ConsString::kFirstOffset));
3563
3564 __ bind(&indirect_string_loaded);
3565 __ lw(result, FieldMemOperand(string, HeapObject::kMapOffset));
3566 __ lbu(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
3567
3568 // Check whether the string is sequential. The only non-sequential
3569 // shapes we support have just been unwrapped above.
3570 // Note that if the original string is a cons or slice with an external
3571 // string as underlying string, we pass that unpacked underlying string with
3572 // the adjusted index to the runtime function.
3573 __ bind(&check_sequential);
3574 STATIC_ASSERT(kSeqStringTag == 0);
3575 __ And(temp, result, Operand(kStringRepresentationMask));
3576 __ Branch(deferred->entry(), ne, temp, Operand(zero_reg));
3577
3578 // Dispatch on the encoding: ASCII or two-byte.
3579 Label ascii_string;
3580 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0);
3581 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0);
3582 __ And(temp, result, Operand(kStringEncodingMask));
3583 __ Branch(&ascii_string, ne, temp, Operand(zero_reg));
3584
3585 // Two-byte string.
3586 // Load the two-byte character code into the result register.
3587 Label done;
3588 __ Addu(result,
3589 string,
3590 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag));
3591 __ sll(temp, index, 1);
3592 __ Addu(result, result, temp);
3593 __ lhu(result, MemOperand(result, 0));
3594 __ Branch(&done);
3595
3596 // ASCII string.
3597 // Load the byte into the result register.
3598 __ bind(&ascii_string);
3599 __ Addu(result,
3600 string,
3601 Operand(SeqAsciiString::kHeaderSize - kHeapObjectTag));
3602 __ Addu(result, result, index);
3603 __ lbu(result, MemOperand(result, 0));
3604
3605 __ bind(&done);
3606 __ bind(deferred->exit()); 3530 __ bind(deferred->exit());
3607 } 3531 }
3608 3532
3609 3533
3610 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) { 3534 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) {
3611 Register string = ToRegister(instr->string()); 3535 Register string = ToRegister(instr->string());
3612 Register result = ToRegister(instr->result()); 3536 Register result = ToRegister(instr->result());
3613 Register scratch = scratch0(); 3537 Register scratch = scratch0();
3614 3538
3615 // TODO(3095996): Get rid of this. For now, we need to make the 3539 // TODO(3095996): Get rid of this. For now, we need to make the
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
4243 FastCloneShallowArrayStub::Mode mode = 4167 FastCloneShallowArrayStub::Mode mode =
4244 constant_elements_kind == FAST_DOUBLE_ELEMENTS 4168 constant_elements_kind == FAST_DOUBLE_ELEMENTS
4245 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS 4169 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS
4246 : FastCloneShallowArrayStub::CLONE_ELEMENTS; 4170 : FastCloneShallowArrayStub::CLONE_ELEMENTS;
4247 FastCloneShallowArrayStub stub(mode, length); 4171 FastCloneShallowArrayStub stub(mode, length);
4248 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); 4172 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
4249 } 4173 }
4250 } 4174 }
4251 4175
4252 4176
4253 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { 4177 void LCodeGen::EmitDeepCopy(Handle<JSObject> object,
4178 Register result,
4179 Register source,
4180 int* offset) {
4181 ASSERT(!source.is(a2));
4182 ASSERT(!result.is(a2));
4183
4184 // Increase the offset so that subsequent objects end up right after
4185 // this one.
4186 int current_offset = *offset;
4187 int size = object->map()->instance_size();
4188 *offset += size;
4189
4190 // Copy object header.
4191 ASSERT(object->properties()->length() == 0);
4192 ASSERT(object->elements()->length() == 0 ||
4193 object->elements()->map() == isolate()->heap()->fixed_cow_array_map());
4194 int inobject_properties = object->map()->inobject_properties();
4195 int header_size = size - inobject_properties * kPointerSize;
4196 for (int i = 0; i < header_size; i += kPointerSize) {
4197 __ lw(a2, FieldMemOperand(source, i));
4198 __ sw(a2, FieldMemOperand(result, current_offset + i));
4199 }
4200
4201 // Copy in-object properties.
4202 for (int i = 0; i < inobject_properties; i++) {
4203 int total_offset = current_offset + object->GetInObjectPropertyOffset(i);
4204 Handle<Object> value = Handle<Object>(object->InObjectPropertyAt(i));
4205 if (value->IsJSObject()) {
4206 Handle<JSObject> value_object = Handle<JSObject>::cast(value);
4207 __ Addu(a2, result, Operand(*offset));
4208 __ sw(a2, FieldMemOperand(result, total_offset));
4209 LoadHeapObject(source, value_object);
4210 EmitDeepCopy(value_object, result, source, offset);
4211 } else if (value->IsHeapObject()) {
4212 LoadHeapObject(a2, Handle<HeapObject>::cast(value));
4213 __ sw(a2, FieldMemOperand(result, total_offset));
4214 } else {
4215 __ li(a2, Operand(value));
4216 __ sw(a2, FieldMemOperand(result, total_offset));
4217 }
4218 }
4219 }
4220
4221
4222 void LCodeGen::DoObjectLiteralFast(LObjectLiteralFast* instr) {
4223 int size = instr->hydrogen()->total_size();
4224
4225 // Allocate all objects that are part of the literal in one big
4226 // allocation. This avoids multiple limit checks.
4227 Label allocated, runtime_allocate;
4228 __ AllocateInNewSpace(size, v0, a2, a3, &runtime_allocate, TAG_OBJECT);
4229 __ jmp(&allocated);
4230
4231 __ bind(&runtime_allocate);
4232 __ li(a0, Operand(Smi::FromInt(size)));
4233 __ push(a0);
4234 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
4235
4236 __ bind(&allocated);
4237 int offset = 0;
4238 LoadHeapObject(a1, instr->hydrogen()->boilerplate());
4239 EmitDeepCopy(instr->hydrogen()->boilerplate(), v0, a1, &offset);
4240 ASSERT_EQ(size, offset);
4241 }
4242
4243
4244 void LCodeGen::DoObjectLiteralGeneric(LObjectLiteralGeneric* instr) {
4254 ASSERT(ToRegister(instr->result()).is(v0)); 4245 ASSERT(ToRegister(instr->result()).is(v0));
4246
4247 Handle<FixedArray> constant_properties =
4248 instr->hydrogen()->constant_properties();
4249
4255 __ lw(t0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 4250 __ lw(t0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
4256 __ lw(t0, FieldMemOperand(t0, JSFunction::kLiteralsOffset)); 4251 __ lw(t0, FieldMemOperand(t0, JSFunction::kLiteralsOffset));
4257 __ li(a3, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); 4252 __ li(a3, Operand(Smi::FromInt(instr->hydrogen()->literal_index())));
4258 __ li(a2, Operand(instr->hydrogen()->constant_properties())); 4253 __ li(a2, Operand(constant_properties));
4259 __ li(a1, Operand(Smi::FromInt(instr->hydrogen()->fast_elements() ? 1 : 0))); 4254 int flags = instr->hydrogen()->fast_elements()
4255 ? ObjectLiteral::kFastElements
4256 : ObjectLiteral::kNoFlags;
4257 __ li(a1, Operand(Smi::FromInt(flags)));
4260 __ Push(t0, a3, a2, a1); 4258 __ Push(t0, a3, a2, a1);
4261 4259
4262 // Pick the right runtime function to call. 4260 // Pick the right runtime function to call.
4261 int properties_count = constant_properties->length() / 2;
4263 if (instr->hydrogen()->depth() > 1) { 4262 if (instr->hydrogen()->depth() > 1) {
4264 CallRuntime(Runtime::kCreateObjectLiteral, 4, instr); 4263 CallRuntime(Runtime::kCreateObjectLiteral, 4, instr);
4264 } else if (flags != ObjectLiteral::kFastElements ||
4265 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) {
4266 CallRuntime(Runtime::kCreateObjectLiteralShallow, 4, instr);
4265 } else { 4267 } else {
4266 CallRuntime(Runtime::kCreateObjectLiteralShallow, 4, instr); 4268 FastCloneShallowObjectStub stub(properties_count);
4269 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
4267 } 4270 }
4268 } 4271 }
4269 4272
4270 4273
4271 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { 4274 void LCodeGen::DoToFastProperties(LToFastProperties* instr) {
4272 ASSERT(ToRegister(instr->InputAt(0)).is(a0)); 4275 ASSERT(ToRegister(instr->InputAt(0)).is(a0));
4273 ASSERT(ToRegister(instr->result()).is(v0)); 4276 ASSERT(ToRegister(instr->result()).is(v0));
4274 __ push(a0); 4277 __ push(a0);
4275 CallRuntime(Runtime::kToFastProperties, 1, instr); 4278 CallRuntime(Runtime::kToFastProperties, 1, instr);
4276 } 4279 }
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
4642 ASSERT(!environment->HasBeenRegistered()); 4645 ASSERT(!environment->HasBeenRegistered());
4643 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); 4646 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt);
4644 ASSERT(osr_pc_offset_ == -1); 4647 ASSERT(osr_pc_offset_ == -1);
4645 osr_pc_offset_ = masm()->pc_offset(); 4648 osr_pc_offset_ = masm()->pc_offset();
4646 } 4649 }
4647 4650
4648 4651
4649 #undef __ 4652 #undef __
4650 4653
4651 } } // namespace v8::internal 4654 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/lithium-codegen-mips.h ('k') | src/mips/lithium-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698