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

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

Issue 7262026: MIPS: port Better codegen for '<expression> === void <literal>'. (Closed)
Patch Set: Created 9 years, 5 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 | 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 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 3965 matching lines...) Expand 10 before | Expand all | Expand 10 after
3976 PrepareForBailout(expr, TOS_REG); 3976 PrepareForBailout(expr, TOS_REG);
3977 __ bind(&done); 3977 __ bind(&done);
3978 3978
3979 context()->Plug(v0); 3979 context()->Plug(v0);
3980 } else { 3980 } else {
3981 // This expression cannot throw a reference error at the top level. 3981 // This expression cannot throw a reference error at the top level.
3982 VisitInCurrentContext(expr); 3982 VisitInCurrentContext(expr);
3983 } 3983 }
3984 } 3984 }
3985 3985
3986 3986 void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr,
3987 bool FullCodeGenerator::TryLiteralCompare(Token::Value op, 3987 Handle<String> check,
3988 Expression* left, 3988 Label* if_true,
3989 Expression* right, 3989 Label* if_false,
3990 Label* if_true, 3990 Label* fall_through) {
3991 Label* if_false,
3992 Label* fall_through) {
3993 if (op != Token::EQ && op != Token::EQ_STRICT) return false;
3994
3995 // Check for the pattern: typeof <expression> == <string literal>.
3996 Literal* right_literal = right->AsLiteral();
3997 if (right_literal == NULL) return false;
3998 Handle<Object> right_literal_value = right_literal->handle();
3999 if (!right_literal_value->IsString()) return false;
4000 UnaryOperation* left_unary = left->AsUnaryOperation();
4001 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false;
4002 Handle<String> check = Handle<String>::cast(right_literal_value);
4003
4004 { AccumulatorValueContext context(this); 3991 { AccumulatorValueContext context(this);
4005 VisitForTypeofValue(left_unary->expression()); 3992 VisitForTypeofValue(expr);
4006 } 3993 }
4007 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); 3994 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
4008 3995
4009 if (check->Equals(isolate()->heap()->number_symbol())) { 3996 if (check->Equals(isolate()->heap()->number_symbol())) {
4010 __ JumpIfSmi(v0, if_true); 3997 __ JumpIfSmi(v0, if_true);
4011 __ lw(v0, FieldMemOperand(v0, HeapObject::kMapOffset)); 3998 __ lw(v0, FieldMemOperand(v0, HeapObject::kMapOffset));
4012 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); 3999 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex);
4013 Split(eq, v0, Operand(at), if_true, if_false, fall_through); 4000 Split(eq, v0, Operand(at), if_true, if_false, fall_through);
4014 } else if (check->Equals(isolate()->heap()->string_symbol())) { 4001 } else if (check->Equals(isolate()->heap()->string_symbol())) {
4015 __ JumpIfSmi(v0, if_false); 4002 __ JumpIfSmi(v0, if_false);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4049 __ Branch(if_false, lt, a1, Operand(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); 4036 __ Branch(if_false, lt, a1, Operand(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE));
4050 __ lbu(a1, FieldMemOperand(v0, Map::kInstanceTypeOffset)); 4037 __ lbu(a1, FieldMemOperand(v0, Map::kInstanceTypeOffset));
4051 __ Branch(if_false, gt, a1, Operand(LAST_NONCALLABLE_SPEC_OBJECT_TYPE)); 4038 __ Branch(if_false, gt, a1, Operand(LAST_NONCALLABLE_SPEC_OBJECT_TYPE));
4052 // Check for undetectable objects => false. 4039 // Check for undetectable objects => false.
4053 __ lbu(a1, FieldMemOperand(v0, Map::kBitFieldOffset)); 4040 __ lbu(a1, FieldMemOperand(v0, Map::kBitFieldOffset));
4054 __ And(a1, a1, Operand(1 << Map::kIsUndetectable)); 4041 __ And(a1, a1, Operand(1 << Map::kIsUndetectable));
4055 Split(eq, a1, Operand(zero_reg), if_true, if_false, fall_through); 4042 Split(eq, a1, Operand(zero_reg), if_true, if_false, fall_through);
4056 } else { 4043 } else {
4057 if (if_false != fall_through) __ jmp(if_false); 4044 if (if_false != fall_through) __ jmp(if_false);
4058 } 4045 }
4059
4060 return true;
4061 } 4046 }
4062 4047
4063 4048
4049 void FullCodeGenerator::EmitLiteralCompareUndefined(Expression* expr,
4050 Label* if_true,
4051 Label* if_false,
4052 Label* fall_through) {
4053 VisitForAccumulatorValue(expr);
4054 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
4055
4056 __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
4057 Split(eq, v0, Operand(at), if_true, if_false, fall_through);
4058 }
4059
4060
4064 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { 4061 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
4065 Comment cmnt(masm_, "[ CompareOperation"); 4062 Comment cmnt(masm_, "[ CompareOperation");
4066 SetSourcePosition(expr->position()); 4063 SetSourcePosition(expr->position());
4067 4064
4068 // Always perform the comparison for its control flow. Pack the result 4065 // Always perform the comparison for its control flow. Pack the result
4069 // into the expression's context after the comparison is performed. 4066 // into the expression's context after the comparison is performed.
4070 4067
4071 Label materialize_true, materialize_false; 4068 Label materialize_true, materialize_false;
4072 Label* if_true = NULL; 4069 Label* if_true = NULL;
4073 Label* if_false = NULL; 4070 Label* if_false = NULL;
4074 Label* fall_through = NULL; 4071 Label* fall_through = NULL;
4075 context()->PrepareTest(&materialize_true, &materialize_false, 4072 context()->PrepareTest(&materialize_true, &materialize_false,
4076 &if_true, &if_false, &fall_through); 4073 &if_true, &if_false, &fall_through);
4077 4074
4078 // First we try a fast inlined version of the compare when one of 4075 // First we try a fast inlined version of the compare when one of
4079 // the operands is a literal. 4076 // the operands is a literal.
4080 Token::Value op = expr->op(); 4077 if (TryLiteralCompare(expr, if_true, if_false, fall_through)) {
4081 Expression* left = expr->left();
4082 Expression* right = expr->right();
4083 if (TryLiteralCompare(op, left, right, if_true, if_false, fall_through)) {
4084 context()->Plug(if_true, if_false); 4078 context()->Plug(if_true, if_false);
4085 return; 4079 return;
4086 } 4080 }
4087 4081
4082 Token::Value op = expr->op();
4088 VisitForStackValue(expr->left()); 4083 VisitForStackValue(expr->left());
4089 switch (op) { 4084 switch (op) {
4090 case Token::IN: 4085 case Token::IN:
4091 VisitForStackValue(expr->right()); 4086 VisitForStackValue(expr->right());
4092 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION); 4087 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION);
4093 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); 4088 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
4094 __ LoadRoot(t0, Heap::kTrueValueRootIndex); 4089 __ LoadRoot(t0, Heap::kTrueValueRootIndex);
4095 Split(eq, v0, Operand(t0), if_true, if_false, fall_through); 4090 Split(eq, v0, Operand(t0), if_true, if_false, fall_through);
4096 break; 4091 break;
4097 4092
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
4319 __ Addu(at, a1, Operand(masm_->CodeObject())); 4314 __ Addu(at, a1, Operand(masm_->CodeObject()));
4320 __ Jump(at); 4315 __ Jump(at);
4321 } 4316 }
4322 4317
4323 4318
4324 #undef __ 4319 #undef __
4325 4320
4326 } } // namespace v8::internal 4321 } } // namespace v8::internal
4327 4322
4328 #endif // V8_TARGET_ARCH_MIPS 4323 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698