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

Side by Side Diff: src/x64/full-codegen-x64.cc

Issue 7216008: Better codegen for '<expression> === void <literal>'. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 6 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
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 3889 matching lines...) Expand 10 before | Expand all | Expand 10 after
3900 __ bind(&done); 3900 __ bind(&done);
3901 3901
3902 context()->Plug(rax); 3902 context()->Plug(rax);
3903 } else { 3903 } else {
3904 // This expression cannot throw a reference error at the top level. 3904 // This expression cannot throw a reference error at the top level.
3905 VisitInCurrentContext(expr); 3905 VisitInCurrentContext(expr);
3906 } 3906 }
3907 } 3907 }
3908 3908
3909 3909
3910 bool FullCodeGenerator::TryLiteralCompare(Token::Value op, 3910 void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr,
3911 Expression* left, 3911 Handle<String> check,
3912 Expression* right, 3912 Label* if_true,
3913 Label* if_true, 3913 Label* if_false,
3914 Label* if_false, 3914 Label* fall_through) {
3915 Label* fall_through) {
3916 if (op != Token::EQ && op != Token::EQ_STRICT) return false;
3917
3918 // Check for the pattern: typeof <expression> == <string literal>.
3919 Literal* right_literal = right->AsLiteral();
3920 if (right_literal == NULL) return false;
3921 Handle<Object> right_literal_value = right_literal->handle();
3922 if (!right_literal_value->IsString()) return false;
3923 UnaryOperation* left_unary = left->AsUnaryOperation();
3924 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false;
3925 Handle<String> check = Handle<String>::cast(right_literal_value);
3926
3927 { AccumulatorValueContext context(this); 3915 { AccumulatorValueContext context(this);
3928 VisitForTypeofValue(left_unary->expression()); 3916 VisitForTypeofValue(expr);
3929 } 3917 }
3930 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); 3918 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
3931 3919
3932 if (check->Equals(isolate()->heap()->number_symbol())) { 3920 if (check->Equals(isolate()->heap()->number_symbol())) {
3933 __ JumpIfSmi(rax, if_true); 3921 __ JumpIfSmi(rax, if_true);
3934 __ movq(rax, FieldOperand(rax, HeapObject::kMapOffset)); 3922 __ movq(rax, FieldOperand(rax, HeapObject::kMapOffset));
3935 __ CompareRoot(rax, Heap::kHeapNumberMapRootIndex); 3923 __ CompareRoot(rax, Heap::kHeapNumberMapRootIndex);
3936 Split(equal, if_true, if_false, fall_through); 3924 Split(equal, if_true, if_false, fall_through);
3937 } else if (check->Equals(isolate()->heap()->string_symbol())) { 3925 } else if (check->Equals(isolate()->heap()->string_symbol())) {
3938 __ JumpIfSmi(rax, if_false); 3926 __ JumpIfSmi(rax, if_false);
(...skipping 30 matching lines...) Expand all
3969 __ j(below, if_false); 3957 __ j(below, if_false);
3970 __ CmpInstanceType(rdx, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); 3958 __ CmpInstanceType(rdx, LAST_NONCALLABLE_SPEC_OBJECT_TYPE);
3971 __ j(above, if_false); 3959 __ j(above, if_false);
3972 // Check for undetectable objects => false. 3960 // Check for undetectable objects => false.
3973 __ testb(FieldOperand(rdx, Map::kBitFieldOffset), 3961 __ testb(FieldOperand(rdx, Map::kBitFieldOffset),
3974 Immediate(1 << Map::kIsUndetectable)); 3962 Immediate(1 << Map::kIsUndetectable));
3975 Split(zero, if_true, if_false, fall_through); 3963 Split(zero, if_true, if_false, fall_through);
3976 } else { 3964 } else {
3977 if (if_false != fall_through) __ jmp(if_false); 3965 if (if_false != fall_through) __ jmp(if_false);
3978 } 3966 }
3979
3980 return true;
3981 } 3967 }
3982 3968
3983 3969
3970 void FullCodeGenerator::EmitLiteralCompareUndefined(Expression* expr,
3971 Label* if_true,
3972 Label* if_false,
3973 Label* fall_through) {
3974 { AccumulatorValueContext context(this);
fschneider 2011/06/21 11:36:08 Same comment as on the ARM file.
Steven 2011/06/22 10:00:53 Done.
3975 VisitForTypeofValue(expr);
3976 }
3977 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
3978
3979 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
3980 Split(equal, if_true, if_false, fall_through);
3981 }
3982
3983
3984 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { 3984 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
3985 Comment cmnt(masm_, "[ CompareOperation"); 3985 Comment cmnt(masm_, "[ CompareOperation");
3986 SetSourcePosition(expr->position()); 3986 SetSourcePosition(expr->position());
3987 3987
3988 // Always perform the comparison for its control flow. Pack the result 3988 // Always perform the comparison for its control flow. Pack the result
3989 // into the expression's context after the comparison is performed. 3989 // into the expression's context after the comparison is performed.
3990 Label materialize_true, materialize_false; 3990 Label materialize_true, materialize_false;
3991 Label* if_true = NULL; 3991 Label* if_true = NULL;
3992 Label* if_false = NULL; 3992 Label* if_false = NULL;
3993 Label* fall_through = NULL; 3993 Label* fall_through = NULL;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
4234 __ ret(0); 4234 __ ret(0);
4235 } 4235 }
4236 4236
4237 4237
4238 #undef __ 4238 #undef __
4239 4239
4240 4240
4241 } } // namespace v8::internal 4241 } } // namespace v8::internal
4242 4242
4243 #endif // V8_TARGET_ARCH_X64 4243 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698