OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3438 __ jmp(&done); | 3438 __ jmp(&done); |
3439 } | 3439 } |
3440 | 3440 |
3441 __ bind(¬_date_object); | 3441 __ bind(¬_date_object); |
3442 __ CallRuntime(Runtime::kThrowNotDateError, 0); | 3442 __ CallRuntime(Runtime::kThrowNotDateError, 0); |
3443 __ bind(&done); | 3443 __ bind(&done); |
3444 context()->Plug(v0); | 3444 context()->Plug(v0); |
3445 } | 3445 } |
3446 | 3446 |
3447 | 3447 |
| 3448 void FullCodeGenerator::EmitSeqStringSetCharCheck(Register string, |
| 3449 Register index, |
| 3450 Register value, |
| 3451 uint32_t encoding_mask) { |
| 3452 __ And(at, index, Operand(kSmiTagMask)); |
| 3453 __ Check(eq, "Non-smi index", at, Operand(zero_reg)); |
| 3454 __ And(at, value, Operand(kSmiTagMask)); |
| 3455 __ Check(eq, "Non-smi value", at, Operand(zero_reg)); |
| 3456 |
| 3457 __ lw(at, FieldMemOperand(string, String::kLengthOffset)); |
| 3458 __ Check(lt, "Index is too large", index, Operand(at)); |
| 3459 |
| 3460 __ Check(ge, "Index is negative", index, Operand(zero_reg)); |
| 3461 |
| 3462 __ lw(at, FieldMemOperand(string, HeapObject::kMapOffset)); |
| 3463 __ lbu(at, FieldMemOperand(at, Map::kInstanceTypeOffset)); |
| 3464 |
| 3465 __ And(at, at, Operand(kStringRepresentationMask | kStringEncodingMask)); |
| 3466 __ Subu(at, at, Operand(encoding_mask)); |
| 3467 __ Check(eq, "Unexpected string type", at, Operand(zero_reg)); |
| 3468 } |
| 3469 |
| 3470 |
3448 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { | 3471 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { |
3449 ZoneList<Expression*>* args = expr->arguments(); | 3472 ZoneList<Expression*>* args = expr->arguments(); |
3450 ASSERT_EQ(3, args->length()); | 3473 ASSERT_EQ(3, args->length()); |
3451 | 3474 |
| 3475 Register string = v0; |
| 3476 Register index = a1; |
| 3477 Register value = a2; |
| 3478 |
3452 VisitForStackValue(args->at(1)); // index | 3479 VisitForStackValue(args->at(1)); // index |
3453 VisitForStackValue(args->at(2)); // value | 3480 VisitForStackValue(args->at(2)); // value |
3454 __ pop(a2); | 3481 __ pop(value); |
3455 __ pop(a1); | 3482 __ pop(index); |
3456 VisitForAccumulatorValue(args->at(0)); // string | 3483 VisitForAccumulatorValue(args->at(0)); // string |
3457 | 3484 |
3458 static const String::Encoding encoding = String::ONE_BYTE_ENCODING; | 3485 if (FLAG_debug_code) { |
3459 SeqStringSetCharGenerator::Generate(masm_, encoding, v0, a1, a2); | 3486 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; |
3460 context()->Plug(v0); | 3487 EmitSeqStringSetCharCheck(string, index, value, one_byte_seq_type); |
| 3488 } |
| 3489 |
| 3490 __ SmiUntag(value, value); |
| 3491 __ Addu(at, |
| 3492 string, |
| 3493 Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
| 3494 __ SmiUntag(index); |
| 3495 __ Addu(at, at, index); |
| 3496 __ sb(value, MemOperand(at)); |
| 3497 context()->Plug(string); |
3461 } | 3498 } |
3462 | 3499 |
3463 | 3500 |
3464 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { | 3501 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { |
3465 ZoneList<Expression*>* args = expr->arguments(); | 3502 ZoneList<Expression*>* args = expr->arguments(); |
3466 ASSERT_EQ(3, args->length()); | 3503 ASSERT_EQ(3, args->length()); |
3467 | 3504 |
| 3505 Register string = v0; |
| 3506 Register index = a1; |
| 3507 Register value = a2; |
| 3508 |
3468 VisitForStackValue(args->at(1)); // index | 3509 VisitForStackValue(args->at(1)); // index |
3469 VisitForStackValue(args->at(2)); // value | 3510 VisitForStackValue(args->at(2)); // value |
3470 __ pop(a2); | 3511 __ pop(value); |
3471 __ pop(a1); | 3512 __ pop(index); |
3472 VisitForAccumulatorValue(args->at(0)); // string | 3513 VisitForAccumulatorValue(args->at(0)); // string |
3473 | 3514 |
3474 static const String::Encoding encoding = String::TWO_BYTE_ENCODING; | 3515 if (FLAG_debug_code) { |
3475 SeqStringSetCharGenerator::Generate(masm_, encoding, v0, a1, a2); | 3516 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; |
3476 context()->Plug(v0); | 3517 EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type); |
| 3518 } |
| 3519 |
| 3520 __ SmiUntag(value, value); |
| 3521 __ Addu(at, |
| 3522 string, |
| 3523 Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| 3524 __ Addu(at, at, index); |
| 3525 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); |
| 3526 __ sh(value, MemOperand(at)); |
| 3527 context()->Plug(string); |
3477 } | 3528 } |
3478 | 3529 |
3479 | 3530 |
3480 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { | 3531 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { |
3481 // Load the arguments on the stack and call the runtime function. | 3532 // Load the arguments on the stack and call the runtime function. |
3482 ZoneList<Expression*>* args = expr->arguments(); | 3533 ZoneList<Expression*>* args = expr->arguments(); |
3483 ASSERT(args->length() == 2); | 3534 ASSERT(args->length() == 2); |
3484 VisitForStackValue(args->at(0)); | 3535 VisitForStackValue(args->at(0)); |
3485 VisitForStackValue(args->at(1)); | 3536 VisitForStackValue(args->at(1)); |
3486 MathPowStub stub(MathPowStub::ON_STACK); | 3537 MathPowStub stub(MathPowStub::ON_STACK); |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4859 *context_length = 0; | 4910 *context_length = 0; |
4860 return previous_; | 4911 return previous_; |
4861 } | 4912 } |
4862 | 4913 |
4863 | 4914 |
4864 #undef __ | 4915 #undef __ |
4865 | 4916 |
4866 } } // namespace v8::internal | 4917 } } // namespace v8::internal |
4867 | 4918 |
4868 #endif // V8_TARGET_ARCH_MIPS | 4919 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |