| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 // Slow case: call the runtime. | 647 // Slow case: call the runtime. |
| 648 frame_->EmitPush(r0); | 648 frame_->EmitPush(r0); |
| 649 frame_->CallRuntime(Runtime::kToBool, 1); | 649 frame_->CallRuntime(Runtime::kToBool, 1); |
| 650 // Convert the result (r0) to a condition code. | 650 // Convert the result (r0) to a condition code. |
| 651 __ cmp(r0, Operand(Factory::false_value())); | 651 __ cmp(r0, Operand(Factory::false_value())); |
| 652 | 652 |
| 653 cc_reg_ = ne; | 653 cc_reg_ = ne; |
| 654 } | 654 } |
| 655 | 655 |
| 656 | 656 |
| 657 class GetPropertyStub : public CodeStub { | |
| 658 public: | |
| 659 GetPropertyStub() { } | |
| 660 | |
| 661 private: | |
| 662 Major MajorKey() { return GetProperty; } | |
| 663 int MinorKey() { return 0; } | |
| 664 void Generate(MacroAssembler* masm); | |
| 665 }; | |
| 666 | |
| 667 | |
| 668 class SetPropertyStub : public CodeStub { | |
| 669 public: | |
| 670 SetPropertyStub() { } | |
| 671 | |
| 672 private: | |
| 673 Major MajorKey() { return SetProperty; } | |
| 674 int MinorKey() { return 0; } | |
| 675 void Generate(MacroAssembler* masm); | |
| 676 }; | |
| 677 | |
| 678 | |
| 679 class GenericBinaryOpStub : public CodeStub { | 657 class GenericBinaryOpStub : public CodeStub { |
| 680 public: | 658 public: |
| 681 GenericBinaryOpStub(Token::Value op, | 659 GenericBinaryOpStub(Token::Value op, |
| 682 OverwriteMode mode) | 660 OverwriteMode mode) |
| 683 : op_(op), mode_(mode) { } | 661 : op_(op), mode_(mode) { } |
| 684 | 662 |
| 685 private: | 663 private: |
| 686 Token::Value op_; | 664 Token::Value op_; |
| 687 OverwriteMode mode_; | 665 OverwriteMode mode_; |
| 688 | 666 |
| (...skipping 3659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4348 frame->EmitPush(result.reg()); | 4326 frame->EmitPush(result.reg()); |
| 4349 break; | 4327 break; |
| 4350 } | 4328 } |
| 4351 | 4329 |
| 4352 default: | 4330 default: |
| 4353 UNREACHABLE(); | 4331 UNREACHABLE(); |
| 4354 } | 4332 } |
| 4355 } | 4333 } |
| 4356 | 4334 |
| 4357 | 4335 |
| 4358 void GetPropertyStub::Generate(MacroAssembler* masm) { | |
| 4359 // sp[0]: key | |
| 4360 // sp[1]: receiver | |
| 4361 Label slow, fast; | |
| 4362 // Get the key and receiver object from the stack. | |
| 4363 __ ldm(ia, sp, r0.bit() | r1.bit()); | |
| 4364 // Check that the key is a smi. | |
| 4365 __ tst(r0, Operand(kSmiTagMask)); | |
| 4366 __ b(ne, &slow); | |
| 4367 __ mov(r0, Operand(r0, ASR, kSmiTagSize)); | |
| 4368 // Check that the object isn't a smi. | |
| 4369 __ tst(r1, Operand(kSmiTagMask)); | |
| 4370 __ b(eq, &slow); | |
| 4371 | |
| 4372 // Check that the object is some kind of JS object EXCEPT JS Value type. | |
| 4373 // In the case that the object is a value-wrapper object, | |
| 4374 // we enter the runtime system to make sure that indexing into string | |
| 4375 // objects work as intended. | |
| 4376 ASSERT(JS_OBJECT_TYPE > JS_VALUE_TYPE); | |
| 4377 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); | |
| 4378 __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset)); | |
| 4379 __ cmp(r2, Operand(JS_OBJECT_TYPE)); | |
| 4380 __ b(lt, &slow); | |
| 4381 | |
| 4382 // Get the elements array of the object. | |
| 4383 __ ldr(r1, FieldMemOperand(r1, JSObject::kElementsOffset)); | |
| 4384 // Check that the object is in fast mode (not dictionary). | |
| 4385 __ ldr(r3, FieldMemOperand(r1, HeapObject::kMapOffset)); | |
| 4386 __ cmp(r3, Operand(Factory::hash_table_map())); | |
| 4387 __ b(eq, &slow); | |
| 4388 // Check that the key (index) is within bounds. | |
| 4389 __ ldr(r3, FieldMemOperand(r1, Array::kLengthOffset)); | |
| 4390 __ cmp(r0, Operand(r3)); | |
| 4391 __ b(lo, &fast); | |
| 4392 | |
| 4393 // Slow case: Push extra copies of the arguments (2). | |
| 4394 __ bind(&slow); | |
| 4395 __ ldm(ia, sp, r0.bit() | r1.bit()); | |
| 4396 __ stm(db_w, sp, r0.bit() | r1.bit()); | |
| 4397 // Do tail-call to runtime routine. | |
| 4398 __ TailCallRuntime(ExternalReference(Runtime::kGetProperty), 2); | |
| 4399 | |
| 4400 // Fast case: Do the load. | |
| 4401 __ bind(&fast); | |
| 4402 __ add(r3, r1, Operand(Array::kHeaderSize - kHeapObjectTag)); | |
| 4403 __ ldr(r0, MemOperand(r3, r0, LSL, kPointerSizeLog2)); | |
| 4404 __ cmp(r0, Operand(Factory::the_hole_value())); | |
| 4405 // In case the loaded value is the_hole we have to consult GetProperty | |
| 4406 // to ensure the prototype chain is searched. | |
| 4407 __ b(eq, &slow); | |
| 4408 | |
| 4409 __ StubReturn(1); | |
| 4410 } | |
| 4411 | |
| 4412 | |
| 4413 void SetPropertyStub::Generate(MacroAssembler* masm) { | |
| 4414 // r0 : value | |
| 4415 // sp[0] : key | |
| 4416 // sp[1] : receiver | |
| 4417 | |
| 4418 Label slow, fast, array, extra, exit; | |
| 4419 // Get the key and the object from the stack. | |
| 4420 __ ldm(ia, sp, r1.bit() | r3.bit()); // r1 = key, r3 = receiver | |
| 4421 // Check that the key is a smi. | |
| 4422 __ tst(r1, Operand(kSmiTagMask)); | |
| 4423 __ b(ne, &slow); | |
| 4424 // Check that the object isn't a smi. | |
| 4425 __ tst(r3, Operand(kSmiTagMask)); | |
| 4426 __ b(eq, &slow); | |
| 4427 // Get the type of the object from its map. | |
| 4428 __ ldr(r2, FieldMemOperand(r3, HeapObject::kMapOffset)); | |
| 4429 __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset)); | |
| 4430 // Check if the object is a JS array or not. | |
| 4431 __ cmp(r2, Operand(JS_ARRAY_TYPE)); | |
| 4432 __ b(eq, &array); | |
| 4433 // Check that the object is some kind of JS object. | |
| 4434 __ cmp(r2, Operand(FIRST_JS_OBJECT_TYPE)); | |
| 4435 __ b(lt, &slow); | |
| 4436 | |
| 4437 | |
| 4438 // Object case: Check key against length in the elements array. | |
| 4439 __ ldr(r3, FieldMemOperand(r3, JSObject::kElementsOffset)); | |
| 4440 // Check that the object is in fast mode (not dictionary). | |
| 4441 __ ldr(r2, FieldMemOperand(r3, HeapObject::kMapOffset)); | |
| 4442 __ cmp(r2, Operand(Factory::hash_table_map())); | |
| 4443 __ b(eq, &slow); | |
| 4444 // Untag the key (for checking against untagged length in the fixed array). | |
| 4445 __ mov(r1, Operand(r1, ASR, kSmiTagSize)); | |
| 4446 // Compute address to store into and check array bounds. | |
| 4447 __ add(r2, r3, Operand(Array::kHeaderSize - kHeapObjectTag)); | |
| 4448 __ add(r2, r2, Operand(r1, LSL, kPointerSizeLog2)); | |
| 4449 __ ldr(ip, FieldMemOperand(r3, Array::kLengthOffset)); | |
| 4450 __ cmp(r1, Operand(ip)); | |
| 4451 __ b(lo, &fast); | |
| 4452 | |
| 4453 | |
| 4454 // Slow case: Push extra copies of the arguments (3). | |
| 4455 __ bind(&slow); | |
| 4456 __ ldm(ia, sp, r1.bit() | r3.bit()); // r0 == value, r1 == key, r3 == object | |
| 4457 __ stm(db_w, sp, r0.bit() | r1.bit() | r3.bit()); | |
| 4458 // Do tail-call to runtime routine. | |
| 4459 __ TailCallRuntime(ExternalReference(Runtime::kSetProperty), 3); | |
| 4460 | |
| 4461 | |
| 4462 // Extra capacity case: Check if there is extra capacity to | |
| 4463 // perform the store and update the length. Used for adding one | |
| 4464 // element to the array by writing to array[array.length]. | |
| 4465 // r0 == value, r1 == key, r2 == elements, r3 == object | |
| 4466 __ bind(&extra); | |
| 4467 __ b(ne, &slow); // do not leave holes in the array | |
| 4468 __ mov(r1, Operand(r1, ASR, kSmiTagSize)); // untag | |
| 4469 __ ldr(ip, FieldMemOperand(r2, Array::kLengthOffset)); | |
| 4470 __ cmp(r1, Operand(ip)); | |
| 4471 __ b(hs, &slow); | |
| 4472 __ mov(r1, Operand(r1, LSL, kSmiTagSize)); // restore tag | |
| 4473 __ add(r1, r1, Operand(1 << kSmiTagSize)); // and increment | |
| 4474 __ str(r1, FieldMemOperand(r3, JSArray::kLengthOffset)); | |
| 4475 __ mov(r3, Operand(r2)); | |
| 4476 // NOTE: Computing the address to store into must take the fact | |
| 4477 // that the key has been incremented into account. | |
| 4478 int displacement = Array::kHeaderSize - kHeapObjectTag - | |
| 4479 ((1 << kSmiTagSize) * 2); | |
| 4480 __ add(r2, r2, Operand(displacement)); | |
| 4481 __ add(r2, r2, Operand(r1, LSL, kPointerSizeLog2 - kSmiTagSize)); | |
| 4482 __ b(&fast); | |
| 4483 | |
| 4484 | |
| 4485 // Array case: Get the length and the elements array from the JS | |
| 4486 // array. Check that the array is in fast mode; if it is the | |
| 4487 // length is always a smi. | |
| 4488 // r0 == value, r3 == object | |
| 4489 __ bind(&array); | |
| 4490 __ ldr(r2, FieldMemOperand(r3, JSObject::kElementsOffset)); | |
| 4491 __ ldr(r1, FieldMemOperand(r2, HeapObject::kMapOffset)); | |
| 4492 __ cmp(r1, Operand(Factory::hash_table_map())); | |
| 4493 __ b(eq, &slow); | |
| 4494 | |
| 4495 // Check the key against the length in the array, compute the | |
| 4496 // address to store into and fall through to fast case. | |
| 4497 __ ldr(r1, MemOperand(sp)); | |
| 4498 // r0 == value, r1 == key, r2 == elements, r3 == object. | |
| 4499 __ ldr(ip, FieldMemOperand(r3, JSArray::kLengthOffset)); | |
| 4500 __ cmp(r1, Operand(ip)); | |
| 4501 __ b(hs, &extra); | |
| 4502 __ mov(r3, Operand(r2)); | |
| 4503 __ add(r2, r2, Operand(Array::kHeaderSize - kHeapObjectTag)); | |
| 4504 __ add(r2, r2, Operand(r1, LSL, kPointerSizeLog2 - kSmiTagSize)); | |
| 4505 | |
| 4506 | |
| 4507 // Fast case: Do the store. | |
| 4508 // r0 == value, r2 == address to store into, r3 == elements | |
| 4509 __ bind(&fast); | |
| 4510 __ str(r0, MemOperand(r2)); | |
| 4511 // Skip write barrier if the written value is a smi. | |
| 4512 __ tst(r0, Operand(kSmiTagMask)); | |
| 4513 __ b(eq, &exit); | |
| 4514 // Update write barrier for the elements array address. | |
| 4515 __ sub(r1, r2, Operand(r3)); | |
| 4516 __ RecordWrite(r3, r1, r2); | |
| 4517 __ bind(&exit); | |
| 4518 __ StubReturn(1); | |
| 4519 } | |
| 4520 | |
| 4521 | |
| 4522 static void HandleBinaryOpSlowCases(MacroAssembler* masm, | 4336 static void HandleBinaryOpSlowCases(MacroAssembler* masm, |
| 4523 Label* not_smi, | 4337 Label* not_smi, |
| 4524 const Builtins::JavaScript& builtin, | 4338 const Builtins::JavaScript& builtin, |
| 4525 Token::Value operation, | 4339 Token::Value operation, |
| 4526 int swi_number, | 4340 int swi_number, |
| 4527 OverwriteMode mode) { | 4341 OverwriteMode mode) { |
| 4528 Label slow; | 4342 Label slow; |
| 4529 if (mode == NO_OVERWRITE) { | 4343 if (mode == NO_OVERWRITE) { |
| 4530 __ bind(not_smi); | 4344 __ bind(not_smi); |
| 4531 } | 4345 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4571 __ mov(r5, Operand(ExternalReference::double_fp_operation(operation))); | 4385 __ mov(r5, Operand(ExternalReference::double_fp_operation(operation))); |
| 4572 #if !defined(__arm__) | 4386 #if !defined(__arm__) |
| 4573 // Notify the simulator that we are calling an add routine in C. | 4387 // Notify the simulator that we are calling an add routine in C. |
| 4574 __ swi(swi_number); | 4388 __ swi(swi_number); |
| 4575 #else | 4389 #else |
| 4576 // Actually call the add routine written in C. | 4390 // Actually call the add routine written in C. |
| 4577 __ Call(r5); | 4391 __ Call(r5); |
| 4578 #endif | 4392 #endif |
| 4579 // Store answer in the overwritable heap number. | 4393 // Store answer in the overwritable heap number. |
| 4580 __ pop(r4); | 4394 __ pop(r4); |
| 4395 #if !defined(__ARM_EABI__) && defined(__arm__) |
| 4396 // Double returned in fp coprocessor register 0 and 1, encoded as register |
| 4397 // cr8. Offsets must be divisible by 4 for coprocessor so we need to |
| 4398 // substract the tag from r4. |
| 4399 __ sub(r5, r4, Operand(kHeapObjectTag)); |
| 4400 __ stc(p1, cr8, MemOperand(r5, HeapNumber::kValueOffset)); |
| 4401 #else |
| 4402 // Double returned in fp coprocessor register 0 and 1. |
| 4581 __ str(r0, FieldMemOperand(r4, HeapNumber::kValueOffset)); | 4403 __ str(r0, FieldMemOperand(r4, HeapNumber::kValueOffset)); |
| 4582 __ str(r1, FieldMemOperand(r4, HeapNumber::kValueOffset + kPointerSize)); | 4404 __ str(r1, FieldMemOperand(r4, HeapNumber::kValueOffset + kPointerSize)); |
| 4405 #endif |
| 4583 __ mov(r0, Operand(r4)); | 4406 __ mov(r0, Operand(r4)); |
| 4584 // And we are done. | 4407 // And we are done. |
| 4585 __ pop(pc); | 4408 __ pop(pc); |
| 4586 } | 4409 } |
| 4587 } | 4410 } |
| 4588 | 4411 |
| 4589 | 4412 |
| 4590 void GenericBinaryOpStub::Generate(MacroAssembler* masm) { | 4413 void GenericBinaryOpStub::Generate(MacroAssembler* masm) { |
| 4591 // r1 : x | 4414 // r1 : x |
| 4592 // r0 : y | 4415 // r0 : y |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5313 __ mov(r2, Operand(0)); | 5136 __ mov(r2, Operand(0)); |
| 5314 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); | 5137 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); |
| 5315 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), | 5138 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), |
| 5316 RelocInfo::CODE_TARGET); | 5139 RelocInfo::CODE_TARGET); |
| 5317 } | 5140 } |
| 5318 | 5141 |
| 5319 | 5142 |
| 5320 #undef __ | 5143 #undef __ |
| 5321 | 5144 |
| 5322 } } // namespace v8::internal | 5145 } } // namespace v8::internal |
| OLD | NEW |