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

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: Applied your comments. 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/ast.h » ('j') | src/ast.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 VisitForAccumulatorValue(expr);
4035 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
4036
4037 __ CompareRoot(r0, Heap::kUndefinedValueRootIndex);
4038 Split(eq, if_true, if_false, fall_through);
4039 }
4040
4041
4044 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { 4042 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
4045 Comment cmnt(masm_, "[ CompareOperation"); 4043 Comment cmnt(masm_, "[ CompareOperation");
4046 SetSourcePosition(expr->position()); 4044 SetSourcePosition(expr->position());
4047 4045
4048 // Always perform the comparison for its control flow. Pack the result 4046 // Always perform the comparison for its control flow. Pack the result
4049 // into the expression's context after the comparison is performed. 4047 // into the expression's context after the comparison is performed.
4050 4048
4051 Label materialize_true, materialize_false; 4049 Label materialize_true, materialize_false;
4052 Label* if_true = NULL; 4050 Label* if_true = NULL;
4053 Label* if_false = NULL; 4051 Label* if_false = NULL;
4054 Label* fall_through = NULL; 4052 Label* fall_through = NULL;
4055 context()->PrepareTest(&materialize_true, &materialize_false, 4053 context()->PrepareTest(&materialize_true, &materialize_false,
4056 &if_true, &if_false, &fall_through); 4054 &if_true, &if_false, &fall_through);
4057 4055
4058 // First we try a fast inlined version of the compare when one of 4056 // First we try a fast inlined version of the compare when one of
4059 // the operands is a literal. 4057 // the operands is a literal.
4060 Token::Value op = expr->op(); 4058 if (TryLiteralCompare(expr, if_true, if_false, fall_through)) {
4061 Expression* left = expr->left();
4062 Expression* right = expr->right();
4063 if (TryLiteralCompare(op, left, right, if_true, if_false, fall_through)) {
4064 context()->Plug(if_true, if_false); 4059 context()->Plug(if_true, if_false);
4065 return; 4060 return;
4066 } 4061 }
4067 4062
4063 Token::Value op = expr->op();
4068 VisitForStackValue(expr->left()); 4064 VisitForStackValue(expr->left());
4069 switch (op) { 4065 switch (op) {
4070 case Token::IN: 4066 case Token::IN:
4071 VisitForStackValue(expr->right()); 4067 VisitForStackValue(expr->right());
4072 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION); 4068 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION);
4073 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); 4069 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
4074 __ LoadRoot(ip, Heap::kTrueValueRootIndex); 4070 __ LoadRoot(ip, Heap::kTrueValueRootIndex);
4075 __ cmp(r0, ip); 4071 __ cmp(r0, ip);
4076 Split(eq, if_true, if_false, fall_through); 4072 Split(eq, if_true, if_false, fall_through);
4077 break; 4073 break;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
4301 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. 4297 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value.
4302 __ add(pc, r1, Operand(masm_->CodeObject())); 4298 __ add(pc, r1, Operand(masm_->CodeObject()));
4303 } 4299 }
4304 4300
4305 4301
4306 #undef __ 4302 #undef __
4307 4303
4308 } } // namespace v8::internal 4304 } } // namespace v8::internal
4309 4305
4310 #endif // V8_TARGET_ARCH_ARM 4306 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/ast.h » ('j') | src/ast.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698