Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 6995048: Kill some dead code. (Closed)
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #if defined(V8_TARGET_ARCH_IA32) 30 #if defined(V8_TARGET_ARCH_IA32)
31 31
32 #include "bootstrapper.h"
32 #include "code-stubs.h" 33 #include "code-stubs.h"
33 #include "bootstrapper.h" 34 #include "isolate.h"
34 #include "jsregexp.h" 35 #include "jsregexp.h"
35 #include "isolate.h"
36 #include "regexp-macro-assembler.h" 36 #include "regexp-macro-assembler.h"
37 37
38 namespace v8 { 38 namespace v8 {
39 namespace internal { 39 namespace internal {
40 40
41 #define __ ACCESS_MASM(masm) 41 #define __ ACCESS_MASM(masm)
42 42
43 void ToNumberStub::Generate(MacroAssembler* masm) { 43 void ToNumberStub::Generate(MacroAssembler* masm) {
44 // The ToNumber stub takes one argument in eax. 44 // The ToNumber stub takes one argument in eax.
45 Label check_heap_number, call_builtin; 45 Label check_heap_number, call_builtin;
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 Label* non_float, 324 Label* non_float,
325 Register scratch); 325 Register scratch);
326 326
327 // Checks that the two floating point numbers on top of the FPU stack 327 // Checks that the two floating point numbers on top of the FPU stack
328 // have int32 values. 328 // have int32 values.
329 static void CheckFloatOperandsAreInt32(MacroAssembler* masm, 329 static void CheckFloatOperandsAreInt32(MacroAssembler* masm,
330 Label* non_int32); 330 Label* non_int32);
331 331
332 // Takes the operands in edx and eax and loads them as integers in eax 332 // Takes the operands in edx and eax and loads them as integers in eax
333 // and ecx. 333 // and ecx.
334 static void LoadAsIntegers(MacroAssembler* masm,
335 TypeInfo type_info,
336 bool use_sse3,
337 Label* operand_conversion_failure);
338 static void LoadNumbersAsIntegers(MacroAssembler* masm,
339 TypeInfo type_info,
340 bool use_sse3,
341 Label* operand_conversion_failure);
342 static void LoadUnknownsAsIntegers(MacroAssembler* masm, 334 static void LoadUnknownsAsIntegers(MacroAssembler* masm,
343 bool use_sse3, 335 bool use_sse3,
344 Label* operand_conversion_failure); 336 Label* operand_conversion_failure);
345 337
346 // Must only be called after LoadUnknownsAsIntegers. Assumes that the 338 // Must only be called after LoadUnknownsAsIntegers. Assumes that the
347 // operands are pushed on the stack, and that their conversions to int32 339 // operands are pushed on the stack, and that their conversions to int32
348 // are in eax and ecx. Checks that the original numbers were in the int32 340 // are in eax and ecx. Checks that the original numbers were in the int32
349 // range. 341 // range.
350 static void CheckLoadedIntegersWereInt32(MacroAssembler* masm, 342 static void CheckLoadedIntegersWereInt32(MacroAssembler* masm,
351 bool use_sse3, 343 bool use_sse3,
(...skipping 21 matching lines...) Expand all
373 Register scratch); 365 Register scratch);
374 }; 366 };
375 367
376 368
377 // Get the integer part of a heap number. Surprisingly, all this bit twiddling 369 // Get the integer part of a heap number. Surprisingly, all this bit twiddling
378 // is faster than using the built-in instructions on floating point registers. 370 // is faster than using the built-in instructions on floating point registers.
379 // Trashes edi and ebx. Dest is ecx. Source cannot be ecx or one of the 371 // Trashes edi and ebx. Dest is ecx. Source cannot be ecx or one of the
380 // trashed registers. 372 // trashed registers.
381 static void IntegerConvert(MacroAssembler* masm, 373 static void IntegerConvert(MacroAssembler* masm,
382 Register source, 374 Register source,
383 TypeInfo type_info,
384 bool use_sse3, 375 bool use_sse3,
385 Label* conversion_failure) { 376 Label* conversion_failure) {
386 ASSERT(!source.is(ecx) && !source.is(edi) && !source.is(ebx)); 377 ASSERT(!source.is(ecx) && !source.is(edi) && !source.is(ebx));
387 Label done, right_exponent, normal_exponent; 378 Label done, right_exponent, normal_exponent;
388 Register scratch = ebx; 379 Register scratch = ebx;
389 Register scratch2 = edi; 380 Register scratch2 = edi;
390 if (type_info.IsInteger32() && CpuFeatures::IsSupported(SSE2)) { 381 // Get exponent word.
391 CpuFeatures::Scope scope(SSE2); 382 __ mov(scratch, FieldOperand(source, HeapNumber::kExponentOffset));
392 __ cvttsd2si(ecx, FieldOperand(source, HeapNumber::kValueOffset)); 383 // Get exponent alone in scratch2.
393 return; 384 __ mov(scratch2, scratch);
394 } 385 __ and_(scratch2, HeapNumber::kExponentMask);
395 if (!type_info.IsInteger32() || !use_sse3) {
396 // Get exponent word.
397 __ mov(scratch, FieldOperand(source, HeapNumber::kExponentOffset));
398 // Get exponent alone in scratch2.
399 __ mov(scratch2, scratch);
400 __ and_(scratch2, HeapNumber::kExponentMask);
401 }
402 if (use_sse3) { 386 if (use_sse3) {
403 CpuFeatures::Scope scope(SSE3); 387 CpuFeatures::Scope scope(SSE3);
404 if (!type_info.IsInteger32()) { 388 // Check whether the exponent is too big for a 64 bit signed integer.
405 // Check whether the exponent is too big for a 64 bit signed integer. 389 static const uint32_t kTooBigExponent =
406 static const uint32_t kTooBigExponent = 390 (HeapNumber::kExponentBias + 63) << HeapNumber::kExponentShift;
407 (HeapNumber::kExponentBias + 63) << HeapNumber::kExponentShift; 391 __ cmp(Operand(scratch2), Immediate(kTooBigExponent));
408 __ cmp(Operand(scratch2), Immediate(kTooBigExponent)); 392 __ j(greater_equal, conversion_failure);
409 __ j(greater_equal, conversion_failure);
410 }
411 // Load x87 register with heap number. 393 // Load x87 register with heap number.
412 __ fld_d(FieldOperand(source, HeapNumber::kValueOffset)); 394 __ fld_d(FieldOperand(source, HeapNumber::kValueOffset));
413 // Reserve space for 64 bit answer. 395 // Reserve space for 64 bit answer.
414 __ sub(Operand(esp), Immediate(sizeof(uint64_t))); // Nolint. 396 __ sub(Operand(esp), Immediate(sizeof(uint64_t))); // Nolint.
415 // Do conversion, which cannot fail because we checked the exponent. 397 // Do conversion, which cannot fail because we checked the exponent.
416 __ fisttp_d(Operand(esp, 0)); 398 __ fisttp_d(Operand(esp, 0));
417 __ mov(ecx, Operand(esp, 0)); // Load low word of answer into ecx. 399 __ mov(ecx, Operand(esp, 0)); // Load low word of answer into ecx.
418 __ add(Operand(esp), Immediate(sizeof(uint64_t))); // Nolint. 400 __ add(Operand(esp), Immediate(sizeof(uint64_t))); // Nolint.
419 } else { 401 } else {
420 // Load ecx with zero. We use this either for the final shift or 402 // Load ecx with zero. We use this either for the final shift or
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 722
741 723
742 void TypeRecordingUnaryOpStub::GenerateHeapNumberCodeBitNot( 724 void TypeRecordingUnaryOpStub::GenerateHeapNumberCodeBitNot(
743 MacroAssembler* masm, 725 MacroAssembler* masm,
744 Label* slow) { 726 Label* slow) {
745 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); 727 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset));
746 __ cmp(edx, masm->isolate()->factory()->heap_number_map()); 728 __ cmp(edx, masm->isolate()->factory()->heap_number_map());
747 __ j(not_equal, slow); 729 __ j(not_equal, slow);
748 730
749 // Convert the heap number in eax to an untagged integer in ecx. 731 // Convert the heap number in eax to an untagged integer in ecx.
750 IntegerConvert(masm, eax, TypeInfo::Unknown(), CpuFeatures::IsSupported(SSE3), 732 IntegerConvert(masm, eax, CpuFeatures::IsSupported(SSE3), slow);
751 slow);
752 733
753 // Do the bitwise operation and check if the result fits in a smi. 734 // Do the bitwise operation and check if the result fits in a smi.
754 Label try_float; 735 Label try_float;
755 __ not_(ecx); 736 __ not_(ecx);
756 __ cmp(ecx, 0xc0000000); 737 __ cmp(ecx, 0xc0000000);
757 __ j(sign, &try_float, Label::kNear); 738 __ j(sign, &try_float, Label::kNear);
758 739
759 // Tag the result as a smi and we're done. 740 // Tag the result as a smi and we're done.
760 STATIC_ASSERT(kSmiTagSize == 1); 741 STATIC_ASSERT(kSmiTagSize == 1);
761 __ lea(eax, Operand(ecx, times_2, kSmiTag)); 742 __ lea(eax, Operand(ecx, times_2, kSmiTag));
(...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after
2400 ASSERT(type_ == TranscendentalCache::LOG); 2381 ASSERT(type_ == TranscendentalCache::LOG);
2401 __ fldln2(); 2382 __ fldln2();
2402 __ fxch(); 2383 __ fxch();
2403 __ fyl2x(); 2384 __ fyl2x();
2404 } 2385 }
2405 } 2386 }
2406 2387
2407 2388
2408 // Input: edx, eax are the left and right objects of a bit op. 2389 // Input: edx, eax are the left and right objects of a bit op.
2409 // Output: eax, ecx are left and right integers for a bit op. 2390 // Output: eax, ecx are left and right integers for a bit op.
2410 void FloatingPointHelper::LoadNumbersAsIntegers(MacroAssembler* masm,
2411 TypeInfo type_info,
2412 bool use_sse3,
2413 Label* conversion_failure) {
2414 // Check float operands.
2415 Label arg1_is_object, check_undefined_arg1;
2416 Label arg2_is_object, check_undefined_arg2;
2417 Label load_arg2, done;
2418
2419 if (!type_info.IsDouble()) {
2420 if (!type_info.IsSmi()) {
2421 __ test(edx, Immediate(kSmiTagMask));
2422 __ j(not_zero, &arg1_is_object);
2423 } else {
2424 if (FLAG_debug_code) __ AbortIfNotSmi(edx);
2425 }
2426 __ SmiUntag(edx);
2427 __ jmp(&load_arg2);
2428 }
2429
2430 __ bind(&arg1_is_object);
2431
2432 // Get the untagged integer version of the edx heap number in ecx.
2433 IntegerConvert(masm, edx, type_info, use_sse3, conversion_failure);
2434 __ mov(edx, ecx);
2435
2436 // Here edx has the untagged integer, eax has a Smi or a heap number.
2437 __ bind(&load_arg2);
2438 if (!type_info.IsDouble()) {
2439 // Test if arg2 is a Smi.
2440 if (!type_info.IsSmi()) {
2441 __ test(eax, Immediate(kSmiTagMask));
2442 __ j(not_zero, &arg2_is_object);
2443 } else {
2444 if (FLAG_debug_code) __ AbortIfNotSmi(eax);
2445 }
2446 __ SmiUntag(eax);
2447 __ mov(ecx, eax);
2448 __ jmp(&done);
2449 }
2450
2451 __ bind(&arg2_is_object);
2452
2453 // Get the untagged integer version of the eax heap number in ecx.
2454 IntegerConvert(masm, eax, type_info, use_sse3, conversion_failure);
2455 __ bind(&done);
2456 __ mov(eax, edx);
2457 }
2458
2459
2460 // Input: edx, eax are the left and right objects of a bit op.
2461 // Output: eax, ecx are left and right integers for a bit op.
2462 void FloatingPointHelper::LoadUnknownsAsIntegers(MacroAssembler* masm, 2391 void FloatingPointHelper::LoadUnknownsAsIntegers(MacroAssembler* masm,
2463 bool use_sse3, 2392 bool use_sse3,
2464 Label* conversion_failure) { 2393 Label* conversion_failure) {
2465 // Check float operands. 2394 // Check float operands.
2466 Label arg1_is_object, check_undefined_arg1; 2395 Label arg1_is_object, check_undefined_arg1;
2467 Label arg2_is_object, check_undefined_arg2; 2396 Label arg2_is_object, check_undefined_arg2;
2468 Label load_arg2, done; 2397 Label load_arg2, done;
2469 2398
2470 // Test if arg1 is a Smi. 2399 // Test if arg1 is a Smi.
2471 __ test(edx, Immediate(kSmiTagMask)); 2400 __ test(edx, Immediate(kSmiTagMask));
2472 __ j(not_zero, &arg1_is_object); 2401 __ j(not_zero, &arg1_is_object);
2473 2402
2474 __ SmiUntag(edx); 2403 __ SmiUntag(edx);
2475 __ jmp(&load_arg2); 2404 __ jmp(&load_arg2);
2476 2405
2477 // If the argument is undefined it converts to zero (ECMA-262, section 9.5). 2406 // If the argument is undefined it converts to zero (ECMA-262, section 9.5).
2478 __ bind(&check_undefined_arg1); 2407 __ bind(&check_undefined_arg1);
2479 Factory* factory = masm->isolate()->factory(); 2408 Factory* factory = masm->isolate()->factory();
2480 __ cmp(edx, factory->undefined_value()); 2409 __ cmp(edx, factory->undefined_value());
2481 __ j(not_equal, conversion_failure); 2410 __ j(not_equal, conversion_failure);
2482 __ mov(edx, Immediate(0)); 2411 __ mov(edx, Immediate(0));
2483 __ jmp(&load_arg2); 2412 __ jmp(&load_arg2);
2484 2413
2485 __ bind(&arg1_is_object); 2414 __ bind(&arg1_is_object);
2486 __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset)); 2415 __ mov(ebx, FieldOperand(edx, HeapObject::kMapOffset));
2487 __ cmp(ebx, factory->heap_number_map()); 2416 __ cmp(ebx, factory->heap_number_map());
2488 __ j(not_equal, &check_undefined_arg1); 2417 __ j(not_equal, &check_undefined_arg1);
2489 2418
2490 // Get the untagged integer version of the edx heap number in ecx. 2419 // Get the untagged integer version of the edx heap number in ecx.
2491 IntegerConvert(masm, 2420 IntegerConvert(masm, edx, use_sse3, conversion_failure);
2492 edx,
2493 TypeInfo::Unknown(),
2494 use_sse3,
2495 conversion_failure);
2496 __ mov(edx, ecx); 2421 __ mov(edx, ecx);
2497 2422
2498 // Here edx has the untagged integer, eax has a Smi or a heap number. 2423 // Here edx has the untagged integer, eax has a Smi or a heap number.
2499 __ bind(&load_arg2); 2424 __ bind(&load_arg2);
2500 2425
2501 // Test if arg2 is a Smi. 2426 // Test if arg2 is a Smi.
2502 __ test(eax, Immediate(kSmiTagMask)); 2427 __ test(eax, Immediate(kSmiTagMask));
2503 __ j(not_zero, &arg2_is_object); 2428 __ j(not_zero, &arg2_is_object);
2504 2429
2505 __ SmiUntag(eax); 2430 __ SmiUntag(eax);
2506 __ mov(ecx, eax); 2431 __ mov(ecx, eax);
2507 __ jmp(&done); 2432 __ jmp(&done);
2508 2433
2509 // If the argument is undefined it converts to zero (ECMA-262, section 9.5). 2434 // If the argument is undefined it converts to zero (ECMA-262, section 9.5).
2510 __ bind(&check_undefined_arg2); 2435 __ bind(&check_undefined_arg2);
2511 __ cmp(eax, factory->undefined_value()); 2436 __ cmp(eax, factory->undefined_value());
2512 __ j(not_equal, conversion_failure); 2437 __ j(not_equal, conversion_failure);
2513 __ mov(ecx, Immediate(0)); 2438 __ mov(ecx, Immediate(0));
2514 __ jmp(&done); 2439 __ jmp(&done);
2515 2440
2516 __ bind(&arg2_is_object); 2441 __ bind(&arg2_is_object);
2517 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); 2442 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
2518 __ cmp(ebx, factory->heap_number_map()); 2443 __ cmp(ebx, factory->heap_number_map());
2519 __ j(not_equal, &check_undefined_arg2); 2444 __ j(not_equal, &check_undefined_arg2);
2520 2445
2521 // Get the untagged integer version of the eax heap number in ecx. 2446 // Get the untagged integer version of the eax heap number in ecx.
2522 IntegerConvert(masm, 2447 IntegerConvert(masm, eax, use_sse3, conversion_failure);
2523 eax,
2524 TypeInfo::Unknown(),
2525 use_sse3,
2526 conversion_failure);
2527 __ bind(&done); 2448 __ bind(&done);
2528 __ mov(eax, edx); 2449 __ mov(eax, edx);
2529 } 2450 }
2530 2451
2531 2452
2532 void FloatingPointHelper::LoadAsIntegers(MacroAssembler* masm,
2533 TypeInfo type_info,
2534 bool use_sse3,
2535 Label* conversion_failure) {
2536 if (type_info.IsNumber()) {
2537 LoadNumbersAsIntegers(masm, type_info, use_sse3, conversion_failure);
2538 } else {
2539 LoadUnknownsAsIntegers(masm, use_sse3, conversion_failure);
2540 }
2541 }
2542
2543
2544 void FloatingPointHelper::CheckLoadedIntegersWereInt32(MacroAssembler* masm, 2453 void FloatingPointHelper::CheckLoadedIntegersWereInt32(MacroAssembler* masm,
2545 bool use_sse3, 2454 bool use_sse3,
2546 Label* not_int32) { 2455 Label* not_int32) {
2547 return; 2456 return;
2548 } 2457 }
2549 2458
2550 2459
2551 void FloatingPointHelper::LoadFloatOperand(MacroAssembler* masm, 2460 void FloatingPointHelper::LoadFloatOperand(MacroAssembler* masm,
2552 Register number) { 2461 Register number) {
2553 Label load_smi, done; 2462 Label load_smi, done;
(...skipping 3687 matching lines...) Expand 10 before | Expand all | Expand 10 after
6241 __ Drop(1); 6150 __ Drop(1);
6242 __ ret(2 * kPointerSize); 6151 __ ret(2 * kPointerSize);
6243 } 6152 }
6244 6153
6245 6154
6246 #undef __ 6155 #undef __
6247 6156
6248 } } // namespace v8::internal 6157 } } // namespace v8::internal
6249 6158
6250 #endif // V8_TARGET_ARCH_IA32 6159 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698