OLD | NEW |
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 2417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2428 | 2428 |
2429 VisitForAccumulatorValue(args->at(0)); | 2429 VisitForAccumulatorValue(args->at(0)); |
2430 | 2430 |
2431 Label materialize_true, materialize_false; | 2431 Label materialize_true, materialize_false; |
2432 Label* if_true = NULL; | 2432 Label* if_true = NULL; |
2433 Label* if_false = NULL; | 2433 Label* if_false = NULL; |
2434 Label* fall_through = NULL; | 2434 Label* fall_through = NULL; |
2435 context()->PrepareTest(&materialize_true, &materialize_false, | 2435 context()->PrepareTest(&materialize_true, &materialize_false, |
2436 &if_true, &if_false, &fall_through); | 2436 &if_true, &if_false, &fall_through); |
2437 | 2437 |
2438 // Just indicate false, as %_IsStringWrapperSafeForDefaultValueOf() is only | 2438 if (FLAG_debug_code) __ AbortIfSmi(rax); |
2439 // used in a few functions in runtime.js which should not normally be hit by | 2439 |
2440 // this compiler. | 2440 // Check whether this map has already been checked to be safe for default |
| 2441 // valueOf. |
| 2442 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); |
| 2443 __ testb(FieldOperand(rbx, Map::kBitField2Offset), |
| 2444 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf)); |
| 2445 __ j(not_zero, if_true); |
| 2446 |
| 2447 // Check for fast case object. Generate false result for slow case object. |
| 2448 __ movq(rcx, FieldOperand(rax, JSObject::kPropertiesOffset)); |
| 2449 __ movq(rcx, FieldOperand(rcx, HeapObject::kMapOffset)); |
| 2450 __ CompareRoot(rcx, Heap::kHashTableMapRootIndex); |
| 2451 __ j(equal, if_false); |
| 2452 |
| 2453 // Look for valueOf symbol in the descriptor array, and indicate false if |
| 2454 // found. The type is not checked, so if it is a transition it is a false |
| 2455 // negative. |
| 2456 __ movq(rbx, FieldOperand(rbx, Map::kInstanceDescriptorsOffset)); |
| 2457 __ movq(rcx, FieldOperand(rbx, FixedArray::kLengthOffset)); |
| 2458 // rbx: descriptor array |
| 2459 // rcx: length of descriptor array |
| 2460 // Calculate the end of the descriptor array. |
| 2461 SmiIndex index = masm_->SmiToIndex(rdx, rcx, kPointerSizeLog2); |
| 2462 __ lea(rcx, |
| 2463 Operand( |
| 2464 rbx, index.reg, index.scale, FixedArray::kHeaderSize)); |
| 2465 // Calculate location of the first key name. |
| 2466 __ addq(rbx, |
| 2467 Immediate(FixedArray::kHeaderSize + |
| 2468 DescriptorArray::kFirstIndex * kPointerSize)); |
| 2469 // Loop through all the keys in the descriptor array. If one of these is the |
| 2470 // symbol valueOf the result is false. |
| 2471 Label entry, loop; |
| 2472 __ jmp(&entry); |
| 2473 __ bind(&loop); |
| 2474 __ movq(rdx, FieldOperand(rbx, 0)); |
| 2475 __ Cmp(rdx, FACTORY->value_of_symbol()); |
| 2476 __ j(equal, if_false); |
| 2477 __ addq(rbx, Immediate(kPointerSize)); |
| 2478 __ bind(&entry); |
| 2479 __ cmpq(rbx, rcx); |
| 2480 __ j(not_equal, &loop); |
| 2481 |
| 2482 // Reload map as register rbx was used as temporary above. |
| 2483 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); |
| 2484 |
| 2485 // If a valueOf property is not found on the object check that it's |
| 2486 // prototype is the un-modified String prototype. If not result is false. |
| 2487 __ movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); |
| 2488 __ testq(rcx, Immediate(kSmiTagMask)); |
| 2489 __ j(zero, if_false); |
| 2490 __ movq(rcx, FieldOperand(rcx, HeapObject::kMapOffset)); |
| 2491 __ movq(rdx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 2492 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalContextOffset)); |
| 2493 __ cmpq(rcx, |
| 2494 ContextOperand(rdx, Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); |
| 2495 __ j(not_equal, if_false); |
| 2496 // Set the bit in the map to indicate that it has been checked safe for |
| 2497 // default valueOf and set true result. |
| 2498 __ or_(FieldOperand(rbx, Map::kBitField2Offset), |
| 2499 Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf)); |
| 2500 __ jmp(if_true); |
| 2501 |
2441 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 2502 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
2442 __ jmp(if_false); | |
2443 context()->Plug(if_true, if_false); | 2503 context()->Plug(if_true, if_false); |
2444 } | 2504 } |
2445 | 2505 |
2446 | 2506 |
2447 void FullCodeGenerator::EmitIsFunction(ZoneList<Expression*>* args) { | 2507 void FullCodeGenerator::EmitIsFunction(ZoneList<Expression*>* args) { |
2448 ASSERT(args->length() == 1); | 2508 ASSERT(args->length() == 1); |
2449 | 2509 |
2450 VisitForAccumulatorValue(args->at(0)); | 2510 VisitForAccumulatorValue(args->at(0)); |
2451 | 2511 |
2452 Label materialize_true, materialize_false; | 2512 Label materialize_true, materialize_false; |
(...skipping 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4276 __ ret(0); | 4336 __ ret(0); |
4277 } | 4337 } |
4278 | 4338 |
4279 | 4339 |
4280 #undef __ | 4340 #undef __ |
4281 | 4341 |
4282 | 4342 |
4283 } } // namespace v8::internal | 4343 } } // namespace v8::internal |
4284 | 4344 |
4285 #endif // V8_TARGET_ARCH_X64 | 4345 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |