Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 3912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3923 __ bind(&done); | 3923 __ bind(&done); |
| 3924 | 3924 |
| 3925 context()->Plug(eax); | 3925 context()->Plug(eax); |
| 3926 } else { | 3926 } else { |
| 3927 // This expression cannot throw a reference error at the top level. | 3927 // This expression cannot throw a reference error at the top level. |
| 3928 VisitInCurrentContext(expr); | 3928 VisitInCurrentContext(expr); |
| 3929 } | 3929 } |
| 3930 } | 3930 } |
| 3931 | 3931 |
| 3932 | 3932 |
| 3933 bool FullCodeGenerator::TryLiteralCompare(Token::Value op, | 3933 void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr, |
| 3934 Expression* left, | 3934 Handle<String> check, |
| 3935 Expression* right, | 3935 Label* if_true, |
| 3936 Label* if_true, | 3936 Label* if_false, |
| 3937 Label* if_false, | 3937 Label* fall_through) { |
| 3938 Label* fall_through) { | |
| 3939 if (op != Token::EQ && op != Token::EQ_STRICT) return false; | |
| 3940 | |
| 3941 // Check for the pattern: typeof <expression> == <string literal>. | |
| 3942 Literal* right_literal = right->AsLiteral(); | |
| 3943 if (right_literal == NULL) return false; | |
| 3944 Handle<Object> right_literal_value = right_literal->handle(); | |
| 3945 if (!right_literal_value->IsString()) return false; | |
| 3946 UnaryOperation* left_unary = left->AsUnaryOperation(); | |
| 3947 if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false; | |
| 3948 Handle<String> check = Handle<String>::cast(right_literal_value); | |
| 3949 | |
| 3950 { AccumulatorValueContext context(this); | 3938 { AccumulatorValueContext context(this); |
| 3951 VisitForTypeofValue(left_unary->expression()); | 3939 VisitForTypeofValue(expr); |
| 3952 } | 3940 } |
| 3953 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 3941 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
| 3954 | 3942 |
| 3955 if (check->Equals(isolate()->heap()->number_symbol())) { | 3943 if (check->Equals(isolate()->heap()->number_symbol())) { |
| 3956 __ JumpIfSmi(eax, if_true); | 3944 __ JumpIfSmi(eax, if_true); |
| 3957 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), | 3945 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), |
| 3958 isolate()->factory()->heap_number_map()); | 3946 isolate()->factory()->heap_number_map()); |
| 3959 Split(equal, if_true, if_false, fall_through); | 3947 Split(equal, if_true, if_false, fall_through); |
| 3960 } else if (check->Equals(isolate()->heap()->string_symbol())) { | 3948 } else if (check->Equals(isolate()->heap()->string_symbol())) { |
| 3961 __ JumpIfSmi(eax, if_false); | 3949 __ JumpIfSmi(eax, if_false); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 3991 __ j(below, if_false); | 3979 __ j(below, if_false); |
| 3992 __ CmpInstanceType(edx, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); | 3980 __ CmpInstanceType(edx, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
| 3993 __ j(above, if_false); | 3981 __ j(above, if_false); |
| 3994 // Check for undetectable objects => false. | 3982 // Check for undetectable objects => false. |
| 3995 __ test_b(FieldOperand(edx, Map::kBitFieldOffset), | 3983 __ test_b(FieldOperand(edx, Map::kBitFieldOffset), |
| 3996 1 << Map::kIsUndetectable); | 3984 1 << Map::kIsUndetectable); |
| 3997 Split(zero, if_true, if_false, fall_through); | 3985 Split(zero, if_true, if_false, fall_through); |
| 3998 } else { | 3986 } else { |
| 3999 if (if_false != fall_through) __ jmp(if_false); | 3987 if (if_false != fall_through) __ jmp(if_false); |
| 4000 } | 3988 } |
| 4001 | |
| 4002 return true; | |
| 4003 } | 3989 } |
| 4004 | 3990 |
| 4005 | 3991 |
| 3992 void FullCodeGenerator::EmitLiteralCompareUndefined(Expression* expr, | |
| 3993 Label* if_true, | |
| 3994 Label* if_false, | |
| 3995 Label* fall_through) { | |
| 3996 { AccumulatorValueContext context(this); | |
|
fschneider
2011/06/21 11:36:08
Same comment as on ARM.
Steven
2011/06/22 10:00:53
Done.
| |
| 3997 VisitForTypeofValue(expr); | |
| 3998 } | |
| 3999 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | |
| 4000 | |
| 4001 __ cmp(eax, isolate()->factory()->undefined_value()); | |
| 4002 Split(equal, if_true, if_false, fall_through); | |
| 4003 } | |
| 4004 | |
| 4005 | |
| 4006 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { | 4006 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
| 4007 Comment cmnt(masm_, "[ CompareOperation"); | 4007 Comment cmnt(masm_, "[ CompareOperation"); |
| 4008 SetSourcePosition(expr->position()); | 4008 SetSourcePosition(expr->position()); |
| 4009 | 4009 |
| 4010 // Always perform the comparison for its control flow. Pack the result | 4010 // Always perform the comparison for its control flow. Pack the result |
| 4011 // into the expression's context after the comparison is performed. | 4011 // into the expression's context after the comparison is performed. |
| 4012 | 4012 |
| 4013 Label materialize_true, materialize_false; | 4013 Label materialize_true, materialize_false; |
| 4014 Label* if_true = NULL; | 4014 Label* if_true = NULL; |
| 4015 Label* if_false = NULL; | 4015 Label* if_false = NULL; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4252 // And return. | 4252 // And return. |
| 4253 __ ret(0); | 4253 __ ret(0); |
| 4254 } | 4254 } |
| 4255 | 4255 |
| 4256 | 4256 |
| 4257 #undef __ | 4257 #undef __ |
| 4258 | 4258 |
| 4259 } } // namespace v8::internal | 4259 } } // namespace v8::internal |
| 4260 | 4260 |
| 4261 #endif // V8_TARGET_ARCH_IA32 | 4261 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |