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 3327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3338 __ jmp(&done); | 3338 __ jmp(&done); |
3339 } | 3339 } |
3340 | 3340 |
3341 __ bind(¬_date_object); | 3341 __ bind(¬_date_object); |
3342 __ CallRuntime(Runtime::kThrowNotDateError, 0); | 3342 __ CallRuntime(Runtime::kThrowNotDateError, 0); |
3343 __ bind(&done); | 3343 __ bind(&done); |
3344 context()->Plug(rax); | 3344 context()->Plug(rax); |
3345 } | 3345 } |
3346 | 3346 |
3347 | 3347 |
| 3348 void FullCodeGenerator::EmitSeqStringSetCharCheck(Register string, |
| 3349 Register index, |
| 3350 Register value, |
| 3351 uint32_t encoding_mask) { |
| 3352 __ Check(masm()->CheckSmi(index), "Non-smi index"); |
| 3353 __ Check(masm()->CheckSmi(value), "Non-smi value"); |
| 3354 |
| 3355 __ SmiCompare(index, FieldOperand(string, String::kLengthOffset)); |
| 3356 __ Check(less, "Index is too large"); |
| 3357 |
| 3358 __ SmiCompare(index, Smi::FromInt(0)); |
| 3359 __ Check(greater_equal, "Index is negative"); |
| 3360 |
| 3361 __ push(value); |
| 3362 __ movq(value, FieldOperand(string, HeapObject::kMapOffset)); |
| 3363 __ movzxbq(value, FieldOperand(value, Map::kInstanceTypeOffset)); |
| 3364 |
| 3365 __ andb(value, Immediate(kStringRepresentationMask | kStringEncodingMask)); |
| 3366 __ cmpq(value, Immediate(encoding_mask)); |
| 3367 __ Check(equal, "Unexpected string type"); |
| 3368 __ pop(value); |
| 3369 } |
| 3370 |
| 3371 |
3348 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { | 3372 void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { |
3349 ZoneList<Expression*>* args = expr->arguments(); | 3373 ZoneList<Expression*>* args = expr->arguments(); |
3350 ASSERT_EQ(3, args->length()); | 3374 ASSERT_EQ(3, args->length()); |
3351 | 3375 |
| 3376 Register string = rax; |
| 3377 Register index = rbx; |
| 3378 Register value = rcx; |
| 3379 |
3352 VisitForStackValue(args->at(1)); // index | 3380 VisitForStackValue(args->at(1)); // index |
3353 VisitForStackValue(args->at(2)); // value | 3381 VisitForStackValue(args->at(2)); // value |
3354 __ pop(rcx); | 3382 __ pop(value); |
3355 __ pop(rbx); | 3383 __ pop(index); |
3356 VisitForAccumulatorValue(args->at(0)); // string | 3384 VisitForAccumulatorValue(args->at(0)); // string |
3357 | 3385 |
3358 static const String::Encoding encoding = String::ONE_BYTE_ENCODING; | 3386 if (FLAG_debug_code) { |
3359 SeqStringSetCharGenerator::Generate(masm_, encoding, rax, rbx, rcx); | 3387 static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; |
3360 context()->Plug(rax); | 3388 EmitSeqStringSetCharCheck(string, index, value, one_byte_seq_type); |
| 3389 } |
| 3390 |
| 3391 __ SmiToInteger32(value, value); |
| 3392 __ SmiToInteger32(index, index); |
| 3393 __ movb(FieldOperand(string, index, times_1, SeqOneByteString::kHeaderSize), |
| 3394 value); |
| 3395 context()->Plug(string); |
3361 } | 3396 } |
3362 | 3397 |
3363 | 3398 |
3364 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { | 3399 void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { |
3365 ZoneList<Expression*>* args = expr->arguments(); | 3400 ZoneList<Expression*>* args = expr->arguments(); |
3366 ASSERT_EQ(3, args->length()); | 3401 ASSERT_EQ(3, args->length()); |
3367 | 3402 |
| 3403 Register string = rax; |
| 3404 Register index = rbx; |
| 3405 Register value = rcx; |
| 3406 |
3368 VisitForStackValue(args->at(1)); // index | 3407 VisitForStackValue(args->at(1)); // index |
3369 VisitForStackValue(args->at(2)); // value | 3408 VisitForStackValue(args->at(2)); // value |
3370 __ pop(rcx); | 3409 __ pop(value); |
3371 __ pop(rbx); | 3410 __ pop(index); |
3372 VisitForAccumulatorValue(args->at(0)); // string | 3411 VisitForAccumulatorValue(args->at(0)); // string |
3373 | 3412 |
3374 static const String::Encoding encoding = String::TWO_BYTE_ENCODING; | 3413 if (FLAG_debug_code) { |
3375 SeqStringSetCharGenerator::Generate(masm_, encoding, rax, rbx, rcx); | 3414 static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; |
| 3415 EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type); |
| 3416 } |
| 3417 |
| 3418 __ SmiToInteger32(value, value); |
| 3419 __ SmiToInteger32(index, index); |
| 3420 __ movw(FieldOperand(string, index, times_2, SeqTwoByteString::kHeaderSize), |
| 3421 value); |
3376 context()->Plug(rax); | 3422 context()->Plug(rax); |
3377 } | 3423 } |
3378 | 3424 |
3379 | 3425 |
3380 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { | 3426 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { |
3381 // Load the arguments on the stack and call the runtime function. | 3427 // Load the arguments on the stack and call the runtime function. |
3382 ZoneList<Expression*>* args = expr->arguments(); | 3428 ZoneList<Expression*>* args = expr->arguments(); |
3383 ASSERT(args->length() == 2); | 3429 ASSERT(args->length() == 2); |
3384 VisitForStackValue(args->at(0)); | 3430 VisitForStackValue(args->at(0)); |
3385 VisitForStackValue(args->at(1)); | 3431 VisitForStackValue(args->at(1)); |
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4815 *context_length = 0; | 4861 *context_length = 0; |
4816 return previous_; | 4862 return previous_; |
4817 } | 4863 } |
4818 | 4864 |
4819 | 4865 |
4820 #undef __ | 4866 #undef __ |
4821 | 4867 |
4822 } } // namespace v8::internal | 4868 } } // namespace v8::internal |
4823 | 4869 |
4824 #endif // V8_TARGET_ARCH_X64 | 4870 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |