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

Side by Side Diff: src/arm/full-codegen-arm.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
« no previous file with comments | « no previous file | src/full-codegen.h » ('j') | src/full-codegen.cc » ('J')
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 3946 matching lines...) Expand 10 before | Expand all | Expand 10 after
3957 __ bind(&done); 3957 __ bind(&done);
3958 3958
3959 context()->Plug(r0); 3959 context()->Plug(r0);
3960 } else { 3960 } else {
3961 // This expression cannot throw a reference error at the top level. 3961 // This expression cannot throw a reference error at the top level.
3962 VisitInCurrentContext(expr); 3962 VisitInCurrentContext(expr);
3963 } 3963 }
3964 } 3964 }
3965 3965
3966 3966
3967 bool FullCodeGenerator::TryLiteralCompare(Token::Value op, 3967 void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr,
3968 Expression* left, 3968 Handle<String> check,
3969 Expression* right, 3969 Label* if_true,
3970 Label* if_true, 3970 Label* if_false,
3971 Label* if_false, 3971 Label* fall_through) {
3972 Label* fall_through) {
3973 if (op != Token::EQ && op != Token::EQ_STRICT) return false;
3974
3975 // Check for the pattern: typeof <expression> == <string literal>.
3976 Literal* right_literal = right->AsLiteral();
3977 if (right_literal == NULL) return false;
3978 Handle<Object> right_literal_value = right_literal->handle();
3979 if (!right_literal_value->IsString()) return false;
3980 UnaryOperation* left_unary = left->AsUnaryOperation();
3981 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false;
3982 Handle<String> check = Handle<String>::cast(right_literal_value);
3983
3984 { AccumulatorValueContext context(this); 3972 { AccumulatorValueContext context(this);
3985 VisitForTypeofValue(left_unary->expression()); 3973 VisitForTypeofValue(expr);
3986 } 3974 }
3987 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); 3975 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
3988 3976
3989 if (check->Equals(isolate()->heap()->number_symbol())) { 3977 if (check->Equals(isolate()->heap()->number_symbol())) {
3990 __ JumpIfSmi(r0, if_true); 3978 __ JumpIfSmi(r0, if_true);
3991 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); 3979 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset));
3992 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); 3980 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex);
3993 __ cmp(r0, ip); 3981 __ cmp(r0, ip);
3994 Split(eq, if_true, if_false, fall_through); 3982 Split(eq, if_true, if_false, fall_through);
3995 } else if (check->Equals(isolate()->heap()->string_symbol())) { 3983 } else if (check->Equals(isolate()->heap()->string_symbol())) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4029 __ b(lt, if_false); 4017 __ b(lt, if_false);
4030 __ CompareInstanceType(r0, r1, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); 4018 __ CompareInstanceType(r0, r1, LAST_NONCALLABLE_SPEC_OBJECT_TYPE);
4031 __ b(gt, if_false); 4019 __ b(gt, if_false);
4032 // Check for undetectable objects => false. 4020 // Check for undetectable objects => false.
4033 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); 4021 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset));
4034 __ tst(r1, Operand(1 << Map::kIsUndetectable)); 4022 __ tst(r1, Operand(1 << Map::kIsUndetectable));
4035 Split(eq, if_true, if_false, fall_through); 4023 Split(eq, if_true, if_false, fall_through);
4036 } else { 4024 } else {
4037 if (if_false != fall_through) __ jmp(if_false); 4025 if (if_false != fall_through) __ jmp(if_false);
4038 } 4026 }
4039
4040 return true;
4041 } 4027 }
4042 4028
4043 4029
4030 void FullCodeGenerator::EmitLiteralCompareUndefined(Expression* expr,
4031 Label* if_true,
4032 Label* if_false,
4033 Label* fall_through) {
4034 { AccumulatorValueContext context(this);
fschneider 2011/06/21 11:36:08 This expression should not be visited in a typeof-
Steven 2011/06/22 10:00:53 Done.
4035 VisitForTypeofValue(expr);
4036 }
4037 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
4038
4039 __ CompareRoot(r0, Heap::kUndefinedValueRootIndex);
4040 Split(eq, if_true, if_false, fall_through);
4041 }
4042
4043
4044 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { 4044 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
4045 Comment cmnt(masm_, "[ CompareOperation"); 4045 Comment cmnt(masm_, "[ CompareOperation");
4046 SetSourcePosition(expr->position()); 4046 SetSourcePosition(expr->position());
4047 4047
4048 // Always perform the comparison for its control flow. Pack the result 4048 // Always perform the comparison for its control flow. Pack the result
4049 // into the expression's context after the comparison is performed. 4049 // into the expression's context after the comparison is performed.
4050 4050
4051 Label materialize_true, materialize_false; 4051 Label materialize_true, materialize_false;
4052 Label* if_true = NULL; 4052 Label* if_true = NULL;
4053 Label* if_false = NULL; 4053 Label* if_false = NULL;
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
4301 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. 4301 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value.
4302 __ add(pc, r1, Operand(masm_->CodeObject())); 4302 __ add(pc, r1, Operand(masm_->CodeObject()));
4303 } 4303 }
4304 4304
4305 4305
4306 #undef __ 4306 #undef __
4307 4307
4308 } } // namespace v8::internal 4308 } } // namespace v8::internal
4309 4309
4310 #endif // V8_TARGET_ARCH_ARM 4310 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/full-codegen.h » ('j') | src/full-codegen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698