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 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3279 cc_reg_ = eq; | 3279 cc_reg_ = eq; |
3280 } | 3280 } |
3281 | 3281 |
3282 | 3282 |
3283 // This should generate code that performs a charCodeAt() call or returns | 3283 // This should generate code that performs a charCodeAt() call or returns |
3284 // undefined in order to trigger the slow case, Runtime_StringCharCodeAt. | 3284 // undefined in order to trigger the slow case, Runtime_StringCharCodeAt. |
3285 // It is not yet implemented on ARM, so it always goes to the slow case. | 3285 // It is not yet implemented on ARM, so it always goes to the slow case. |
3286 void CodeGenerator::GenerateFastCharCodeAt(ZoneList<Expression*>* args) { | 3286 void CodeGenerator::GenerateFastCharCodeAt(ZoneList<Expression*>* args) { |
3287 VirtualFrame::SpilledScope spilled_scope; | 3287 VirtualFrame::SpilledScope spilled_scope; |
3288 ASSERT(args->length() == 2); | 3288 ASSERT(args->length() == 2); |
3289 Comment(masm_, "[ GenerateFastCharCodeAt"); | |
3290 | |
3291 LoadAndSpill(args->at(0)); | |
3292 LoadAndSpill(args->at(1)); | |
3293 frame_->EmitPop(r0); // Index. | |
3294 frame_->EmitPop(r1); // String. | |
3295 | |
3296 Label slow, end, not_a_flat_string, ascii_string, try_again_with_new_string; | |
3297 | |
3298 __ tst(r1, Operand(kSmiTagMask)); | |
3299 __ b(eq, &slow); // The 'string' was a Smi. | |
3300 | |
3301 ASSERT(kSmiTag == 0); | |
3302 __ tst(r0, Operand(kSmiTagMask | 0x80000000u)); | |
3303 __ b(ne, &slow); // The index was negative or not a Smi. | |
3304 | |
3305 __ bind(&try_again_with_new_string); | |
3306 __ CompareObjectType(r1, r2, r2, FIRST_NONSTRING_TYPE); | |
3307 __ b(ge, &slow); | |
3308 | |
3309 // Now r2 has the string type. | |
3310 __ ldr(r3, FieldMemOperand(r1, String::kLengthOffset)); | |
3311 __ and_(r4, r2, Operand(kStringSizeMask)); | |
3312 __ add(r4, r4, Operand(String::kLongLengthShift)); | |
3313 __ mov(r3, Operand(r3, LSR, r4)); | |
3314 // Now r3 has the length of the string. Compare with the index. | |
3315 __ cmp(r3, Operand(r0, LSR, kSmiTagSize)); | |
3316 __ b(le, &slow); | |
3317 | |
3318 // Here we know the index is in range. Check that string is sequential. | |
3319 ASSERT_EQ(0, kSeqStringTag); | |
3320 __ tst(r2, Operand(kStringRepresentationMask)); | |
3321 __ b(ne, ¬_a_flat_string); | |
3322 | |
3323 // Check whether it is an ASCII string. | |
3324 ASSERT_EQ(0, kTwoByteStringTag); | |
3325 __ tst(r2, Operand(kStringEncodingMask)); | |
3326 __ b(ne, &ascii_string); | |
3327 | |
3328 // 2-byte string. We can add without shifting since the Smi tag size is the | |
3329 // log2 of the number of bytes in a two-byte character. | |
3330 ASSERT_EQ(1, kSmiTagSize); | |
Lasse Reichstein
2009/11/18 10:04:08
Might also want to assert that kSmiShiftSize is ze
| |
3331 __ add(r1, r1, Operand(r0)); | |
3332 __ ldrh(r0, FieldMemOperand(r1, SeqTwoByteString::kHeaderSize)); | |
3333 __ mov(r0, Operand(r0, LSL, kSmiTagSize)); | |
3334 __ jmp(&end); | |
3335 | |
3336 __ bind(&ascii_string); | |
3337 __ add(r1, r1, Operand(r0, LSR, kSmiTagSize)); | |
3338 __ ldrb(r0, FieldMemOperand(r1, SeqAsciiString::kHeaderSize)); | |
3339 __ mov(r0, Operand(r0, LSL, kSmiTagSize)); | |
3340 __ jmp(&end); | |
3341 | |
3342 __ bind(¬_a_flat_string); | |
3343 __ and_(r2, r2, Operand(kStringRepresentationMask)); | |
3344 __ cmp(r2, Operand(kConsStringTag)); | |
3345 __ b(ne, &slow); | |
3346 | |
3347 // ConsString. | |
3348 // Check that the right hand side is the empty string (ie if this is really a | |
3349 // flat string in a cons string). If that is not the case we would rather go | |
3350 // to the runtime system now, to flatten the string. | |
3351 __ ldr(r2, FieldMemOperand(r1, ConsString::kSecondOffset)); | |
3352 __ LoadRoot(r3, Heap::kEmptyStringRootIndex); | |
3353 __ cmp(r2, Operand(r3)); | |
3354 __ b(ne, &slow); | |
3355 | |
3356 // Get the first of the two strings. | |
3357 __ ldr(r1, FieldMemOperand(r1, ConsString::kFirstOffset)); | |
3358 __ jmp(&try_again_with_new_string); | |
3359 | |
3360 __ bind(&slow); | |
3289 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 3361 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
3362 | |
3363 __ bind(&end); | |
3290 frame_->EmitPush(r0); | 3364 frame_->EmitPush(r0); |
3291 } | 3365 } |
3292 | 3366 |
3293 | 3367 |
3294 void CodeGenerator::GenerateIsArray(ZoneList<Expression*>* args) { | 3368 void CodeGenerator::GenerateIsArray(ZoneList<Expression*>* args) { |
3295 VirtualFrame::SpilledScope spilled_scope; | 3369 VirtualFrame::SpilledScope spilled_scope; |
3296 ASSERT(args->length() == 1); | 3370 ASSERT(args->length() == 1); |
3297 LoadAndSpill(args->at(0)); | 3371 LoadAndSpill(args->at(0)); |
3298 JumpTarget answer; | 3372 JumpTarget answer; |
3299 // We need the CC bits to come out as not_equal in the case where the | 3373 // We need the CC bits to come out as not_equal in the case where the |
(...skipping 3053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6353 int CompareStub::MinorKey() { | 6427 int CompareStub::MinorKey() { |
6354 // Encode the two parameters in a unique 16 bit value. | 6428 // Encode the two parameters in a unique 16 bit value. |
6355 ASSERT(static_cast<unsigned>(cc_) >> 28 < (1 << 15)); | 6429 ASSERT(static_cast<unsigned>(cc_) >> 28 < (1 << 15)); |
6356 return (static_cast<unsigned>(cc_) >> 27) | (strict_ ? 1 : 0); | 6430 return (static_cast<unsigned>(cc_) >> 27) | (strict_ ? 1 : 0); |
6357 } | 6431 } |
6358 | 6432 |
6359 | 6433 |
6360 #undef __ | 6434 #undef __ |
6361 | 6435 |
6362 } } // namespace v8::internal | 6436 } } // namespace v8::internal |
OLD | NEW |