Chromium Code Reviews| 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 2436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2447 Label* conversion_failure) { | 2447 Label* conversion_failure) { |
| 2448 // Check float operands. | 2448 // Check float operands. |
| 2449 Label arg1_is_object, check_undefined_arg1; | 2449 Label arg1_is_object, check_undefined_arg1; |
| 2450 Label arg2_is_object, check_undefined_arg2; | 2450 Label arg2_is_object, check_undefined_arg2; |
| 2451 Label load_arg2, done; | 2451 Label load_arg2, done; |
| 2452 | 2452 |
| 2453 // Test if arg1 is a Smi. | 2453 // Test if arg1 is a Smi. |
| 2454 __ JumpIfNotSmi(edx, &arg1_is_object, Label::kNear); | 2454 __ JumpIfNotSmi(edx, &arg1_is_object, Label::kNear); |
| 2455 | 2455 |
| 2456 __ SmiUntag(edx); | 2456 __ SmiUntag(edx); |
| 2457 __ jmp(&load_arg2, Label::kNear); | 2457 __ jmp(&load_arg2); |
| 2458 | 2458 |
| 2459 // If the argument is undefined it converts to zero (ECMA-262, section 9.5). | 2459 // If the argument is undefined it converts to zero (ECMA-262, section 9.5). |
| 2460 __ bind(&check_undefined_arg1); | 2460 __ bind(&check_undefined_arg1); |
| 2461 Factory* factory = masm->isolate()->factory(); | 2461 Factory* factory = masm->isolate()->factory(); |
| 2462 __ cmp(edx, factory->undefined_value()); | 2462 __ cmp(edx, factory->undefined_value()); |
| 2463 __ j(not_equal, conversion_failure); | 2463 __ j(not_equal, conversion_failure); |
| 2464 __ mov(edx, Immediate(0)); | 2464 __ mov(edx, Immediate(0)); |
| 2465 __ jmp(&load_arg2, Label::kNear); | 2465 __ jmp(&load_arg2); |
| 2466 | 2466 |
| 2467 __ bind(&arg1_is_object); | 2467 __ bind(&arg1_is_object); |
| 2468 __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset)); | 2468 __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset)); |
| 2469 __ cmp(ebx, factory->heap_number_map()); | 2469 __ cmp(ebx, factory->heap_number_map()); |
| 2470 __ j(not_equal, &check_undefined_arg1); | 2470 __ j(not_equal, &check_undefined_arg1); |
| 2471 | 2471 |
| 2472 // Get the untagged integer version of the edx heap number in ecx. | 2472 // Get the untagged integer version of the edx heap number in ecx. |
| 2473 IntegerConvert(masm, edx, use_sse3, conversion_failure); | 2473 IntegerConvert(masm, edx, use_sse3, conversion_failure); |
|
Yang
2011/08/26 11:53:30
Turned out that IntegerConvert generates a lot of
| |
| 2474 __ mov(edx, ecx); | 2474 __ mov(edx, ecx); |
| 2475 | 2475 |
| 2476 // Here edx has the untagged integer, eax has a Smi or a heap number. | 2476 // Here edx has the untagged integer, eax has a Smi or a heap number. |
| 2477 __ bind(&load_arg2); | 2477 __ bind(&load_arg2); |
| 2478 | 2478 |
| 2479 // Test if arg2 is a Smi. | 2479 // Test if arg2 is a Smi. |
| 2480 __ JumpIfNotSmi(eax, &arg2_is_object, Label::kNear); | 2480 __ JumpIfNotSmi(eax, &arg2_is_object, Label::kNear); |
| 2481 | 2481 |
| 2482 __ SmiUntag(eax); | 2482 __ SmiUntag(eax); |
| 2483 __ mov(ecx, eax); | 2483 __ mov(ecx, eax); |
| 2484 __ jmp(&done, Label::kNear); | 2484 __ jmp(&done); |
| 2485 | 2485 |
| 2486 // If the argument is undefined it converts to zero (ECMA-262, section 9.5). | 2486 // If the argument is undefined it converts to zero (ECMA-262, section 9.5). |
| 2487 __ bind(&check_undefined_arg2); | 2487 __ bind(&check_undefined_arg2); |
| 2488 __ cmp(eax, factory->undefined_value()); | 2488 __ cmp(eax, factory->undefined_value()); |
| 2489 __ j(not_equal, conversion_failure); | 2489 __ j(not_equal, conversion_failure); |
| 2490 __ mov(ecx, Immediate(0)); | 2490 __ mov(ecx, Immediate(0)); |
| 2491 __ jmp(&done, Label::kNear); | 2491 __ jmp(&done); |
| 2492 | 2492 |
| 2493 __ bind(&arg2_is_object); | 2493 __ bind(&arg2_is_object); |
| 2494 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 2494 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 2495 __ cmp(ebx, factory->heap_number_map()); | 2495 __ cmp(ebx, factory->heap_number_map()); |
| 2496 __ j(not_equal, &check_undefined_arg2); | 2496 __ j(not_equal, &check_undefined_arg2); |
| 2497 | 2497 |
| 2498 // Get the untagged integer version of the eax heap number in ecx. | 2498 // Get the untagged integer version of the eax heap number in ecx. |
| 2499 IntegerConvert(masm, eax, use_sse3, conversion_failure); | 2499 IntegerConvert(masm, eax, use_sse3, conversion_failure); |
| 2500 __ bind(&done); | 2500 __ bind(&done); |
| 2501 __ mov(eax, edx); | 2501 __ mov(eax, edx); |
| (...skipping 3863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6365 __ Drop(1); | 6365 __ Drop(1); |
| 6366 __ ret(2 * kPointerSize); | 6366 __ ret(2 * kPointerSize); |
| 6367 } | 6367 } |
| 6368 | 6368 |
| 6369 | 6369 |
| 6370 #undef __ | 6370 #undef __ |
| 6371 | 6371 |
| 6372 } } // namespace v8::internal | 6372 } } // namespace v8::internal |
| 6373 | 6373 |
| 6374 #endif // V8_TARGET_ARCH_IA32 | 6374 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |