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

Side by Side Diff: src/ia32/codegen-ia32.cc

Issue 1233003: Speed up conversion of untagged int32 result if we know it must be a smi. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 } 483 }
484 484
485 485
486 void CodeGenerator::LoadInSafeInt32Mode(Expression* expr, 486 void CodeGenerator::LoadInSafeInt32Mode(Expression* expr,
487 BreakTarget* unsafe_bailout) { 487 BreakTarget* unsafe_bailout) {
488 set_unsafe_bailout(unsafe_bailout); 488 set_unsafe_bailout(unsafe_bailout);
489 set_in_safe_int32_mode(true); 489 set_in_safe_int32_mode(true);
490 Load(expr); 490 Load(expr);
491 Result value = frame_->Pop(); 491 Result value = frame_->Pop();
492 ASSERT(frame_->HasNoUntaggedInt32Elements()); 492 ASSERT(frame_->HasNoUntaggedInt32Elements());
493 ConvertInt32ResultToNumber(&value); 493 if (expr->GuaranteedSmiResult()) {
494 ConvertInt32ResultToSmi(&value);
495 } else {
496 ConvertInt32ResultToNumber(&value);
497 }
494 set_in_safe_int32_mode(false); 498 set_in_safe_int32_mode(false);
495 set_unsafe_bailout(NULL); 499 set_unsafe_bailout(NULL);
496 frame_->Push(&value); 500 frame_->Push(&value);
497 } 501 }
498 502
499 503
500 void CodeGenerator::LoadWithSafeInt32ModeDisabled(Expression* expr) { 504 void CodeGenerator::LoadWithSafeInt32ModeDisabled(Expression* expr) {
501 set_safe_int32_mode_enabled(false); 505 set_safe_int32_mode_enabled(false);
502 Load(expr); 506 Load(expr);
503 set_safe_int32_mode_enabled(true); 507 set_safe_int32_mode_enabled(true);
504 } 508 }
505 509
506 510
511 void CodeGenerator::ConvertInt32ResultToSmi(Result* value) {
512 ASSERT(value->is_untagged_int32());
513 if (value->is_register()) {
514 __ add(value->reg(), Operand(value->reg()));
515 } else {
516 ASSERT(value->is_constant());
517 ASSERT(value->handle()->IsSmi());
518 }
519 value->set_untagged_int32(false);
520 value->set_number_info(NumberInfo::Smi());
521 }
522
523
507 void CodeGenerator::ConvertInt32ResultToNumber(Result* value) { 524 void CodeGenerator::ConvertInt32ResultToNumber(Result* value) {
508 ASSERT(value->is_untagged_int32()); 525 ASSERT(value->is_untagged_int32());
509 if (value->is_register()) { 526 if (value->is_register()) {
510 Register val = value->reg(); 527 Register val = value->reg();
511 JumpTarget done; 528 JumpTarget done;
512 __ add(val, Operand(val)); 529 __ add(val, Operand(val));
513 done.Branch(no_overflow, value); 530 done.Branch(no_overflow, value);
514 __ sar(val, 1); 531 __ sar(val, 1);
515 // If there was an overflow, bits 30 and 31 of the original number disagree. 532 // If there was an overflow, bits 30 and 31 of the original number disagree.
516 __ xor_(val, 0x80000000u); 533 __ xor_(val, 0x80000000u);
(...skipping 28 matching lines...) Expand all
545 RegisterFile empty_regs; 562 RegisterFile empty_regs;
546 SetFrame(clone, &empty_regs); 563 SetFrame(clone, &empty_regs);
547 __ bind(&allocation_failed); 564 __ bind(&allocation_failed);
548 unsafe_bailout_->Jump(); 565 unsafe_bailout_->Jump();
549 566
550 done.Bind(value); 567 done.Bind(value);
551 } else { 568 } else {
552 ASSERT(value->is_constant()); 569 ASSERT(value->is_constant());
553 } 570 }
554 value->set_untagged_int32(false); 571 value->set_untagged_int32(false);
572 value->set_number_info(NumberInfo::Integer32());
555 } 573 }
556 574
557 575
558 void CodeGenerator::Load(Expression* expr) { 576 void CodeGenerator::Load(Expression* expr) {
559 #ifdef DEBUG 577 #ifdef DEBUG
560 int original_height = frame_->height(); 578 int original_height = frame_->height();
561 #endif 579 #endif
562 ASSERT(!in_spilled_code()); 580 ASSERT(!in_spilled_code());
563 581
564 // If the expression should be a side-effect-free 32-bit int computation, 582 // If the expression should be a side-effect-free 32-bit int computation,
(...skipping 11974 matching lines...) Expand 10 before | Expand all | Expand 10 after
12539 12557
12540 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 12558 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
12541 // tagged as a small integer. 12559 // tagged as a small integer.
12542 __ bind(&runtime); 12560 __ bind(&runtime);
12543 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 12561 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
12544 } 12562 }
12545 12563
12546 #undef __ 12564 #undef __
12547 12565
12548 } } // namespace v8::internal 12566 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698