| 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 3885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3896 | 3896 |
| 3897 context()->Plug(r0); | 3897 context()->Plug(r0); |
| 3898 } else { | 3898 } else { |
| 3899 // This expression cannot throw a reference error at the top level. | 3899 // This expression cannot throw a reference error at the top level. |
| 3900 VisitInCurrentContext(expr); | 3900 VisitInCurrentContext(expr); |
| 3901 } | 3901 } |
| 3902 } | 3902 } |
| 3903 | 3903 |
| 3904 | 3904 |
| 3905 void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr, | 3905 void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr, |
| 3906 Handle<String> check, | 3906 Handle<String> check) { |
| 3907 Label* if_true, | 3907 Label materialize_true, materialize_false; |
| 3908 Label* if_false, | 3908 Label* if_true = NULL; |
| 3909 Label* fall_through) { | 3909 Label* if_false = NULL; |
| 3910 Label* fall_through = NULL; |
| 3911 context()->PrepareTest(&materialize_true, &materialize_false, |
| 3912 &if_true, &if_false, &fall_through); |
| 3913 |
| 3910 { AccumulatorValueContext context(this); | 3914 { AccumulatorValueContext context(this); |
| 3911 VisitForTypeofValue(expr); | 3915 VisitForTypeofValue(expr); |
| 3912 } | 3916 } |
| 3913 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 3917 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
| 3914 | 3918 |
| 3915 if (check->Equals(isolate()->heap()->number_symbol())) { | 3919 if (check->Equals(isolate()->heap()->number_symbol())) { |
| 3916 __ JumpIfSmi(r0, if_true); | 3920 __ JumpIfSmi(r0, if_true); |
| 3917 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); | 3921 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 3918 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); | 3922 __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
| 3919 __ cmp(r0, ip); | 3923 __ cmp(r0, ip); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3961 __ b(lt, if_false); | 3965 __ b(lt, if_false); |
| 3962 __ CompareInstanceType(r0, r1, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); | 3966 __ CompareInstanceType(r0, r1, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
| 3963 __ b(gt, if_false); | 3967 __ b(gt, if_false); |
| 3964 // Check for undetectable objects => false. | 3968 // Check for undetectable objects => false. |
| 3965 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); | 3969 __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); |
| 3966 __ tst(r1, Operand(1 << Map::kIsUndetectable)); | 3970 __ tst(r1, Operand(1 << Map::kIsUndetectable)); |
| 3967 Split(eq, if_true, if_false, fall_through); | 3971 Split(eq, if_true, if_false, fall_through); |
| 3968 } else { | 3972 } else { |
| 3969 if (if_false != fall_through) __ jmp(if_false); | 3973 if (if_false != fall_through) __ jmp(if_false); |
| 3970 } | 3974 } |
| 3971 } | 3975 context()->Plug(if_true, if_false); |
| 3972 | |
| 3973 | |
| 3974 void FullCodeGenerator::EmitLiteralCompareUndefined(Expression* expr, | |
| 3975 Label* if_true, | |
| 3976 Label* if_false, | |
| 3977 Label* fall_through) { | |
| 3978 VisitForAccumulatorValue(expr); | |
| 3979 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | |
| 3980 | |
| 3981 __ CompareRoot(r0, Heap::kUndefinedValueRootIndex); | |
| 3982 Split(eq, if_true, if_false, fall_through); | |
| 3983 } | 3976 } |
| 3984 | 3977 |
| 3985 | 3978 |
| 3986 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { | 3979 void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
| 3987 Comment cmnt(masm_, "[ CompareOperation"); | 3980 Comment cmnt(masm_, "[ CompareOperation"); |
| 3988 SetSourcePosition(expr->position()); | 3981 SetSourcePosition(expr->position()); |
| 3989 | 3982 |
| 3983 // First we try a fast inlined version of the compare when one of |
| 3984 // the operands is a literal. |
| 3985 if (TryLiteralCompare(expr)) return; |
| 3986 |
| 3990 // Always perform the comparison for its control flow. Pack the result | 3987 // Always perform the comparison for its control flow. Pack the result |
| 3991 // into the expression's context after the comparison is performed. | 3988 // into the expression's context after the comparison is performed. |
| 3992 | |
| 3993 Label materialize_true, materialize_false; | 3989 Label materialize_true, materialize_false; |
| 3994 Label* if_true = NULL; | 3990 Label* if_true = NULL; |
| 3995 Label* if_false = NULL; | 3991 Label* if_false = NULL; |
| 3996 Label* fall_through = NULL; | 3992 Label* fall_through = NULL; |
| 3997 context()->PrepareTest(&materialize_true, &materialize_false, | 3993 context()->PrepareTest(&materialize_true, &materialize_false, |
| 3998 &if_true, &if_false, &fall_through); | 3994 &if_true, &if_false, &fall_through); |
| 3999 | 3995 |
| 4000 // First we try a fast inlined version of the compare when one of | |
| 4001 // the operands is a literal. | |
| 4002 if (TryLiteralCompare(expr, if_true, if_false, fall_through)) { | |
| 4003 context()->Plug(if_true, if_false); | |
| 4004 return; | |
| 4005 } | |
| 4006 | |
| 4007 Token::Value op = expr->op(); | 3996 Token::Value op = expr->op(); |
| 4008 VisitForStackValue(expr->left()); | 3997 VisitForStackValue(expr->left()); |
| 4009 switch (op) { | 3998 switch (op) { |
| 4010 case Token::IN: | 3999 case Token::IN: |
| 4011 VisitForStackValue(expr->right()); | 4000 VisitForStackValue(expr->right()); |
| 4012 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION); | 4001 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION); |
| 4013 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); | 4002 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); |
| 4014 __ LoadRoot(ip, Heap::kTrueValueRootIndex); | 4003 __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
| 4015 __ cmp(r0, ip); | 4004 __ cmp(r0, ip); |
| 4016 Split(eq, if_true, if_false, fall_through); | 4005 Split(eq, if_true, if_false, fall_through); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4083 Split(cond, if_true, if_false, fall_through); | 4072 Split(cond, if_true, if_false, fall_through); |
| 4084 } | 4073 } |
| 4085 } | 4074 } |
| 4086 | 4075 |
| 4087 // Convert the result of the comparison into one expected for this | 4076 // Convert the result of the comparison into one expected for this |
| 4088 // expression's context. | 4077 // expression's context. |
| 4089 context()->Plug(if_true, if_false); | 4078 context()->Plug(if_true, if_false); |
| 4090 } | 4079 } |
| 4091 | 4080 |
| 4092 | 4081 |
| 4093 void FullCodeGenerator::EmitLiteralCompareNull(Expression* expr, | 4082 void FullCodeGenerator::EmitLiteralCompareNil(CompareOperation* expr, |
| 4094 bool is_strict, | 4083 Expression* sub_expr, |
| 4095 Label* if_true, | 4084 NilValue nil) { |
| 4096 Label* if_false, | 4085 Label materialize_true, materialize_false; |
| 4097 Label* fall_through) { | 4086 Label* if_true = NULL; |
| 4098 VisitForAccumulatorValue(expr); | 4087 Label* if_false = NULL; |
| 4088 Label* fall_through = NULL; |
| 4089 context()->PrepareTest(&materialize_true, &materialize_false, |
| 4090 &if_true, &if_false, &fall_through); |
| 4091 |
| 4092 VisitForAccumulatorValue(sub_expr); |
| 4099 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); | 4093 PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false); |
| 4100 __ LoadRoot(r1, Heap::kNullValueRootIndex); | 4094 Heap::RootListIndex nil_value = nil == kNullValue ? |
| 4095 Heap::kNullValueRootIndex : |
| 4096 Heap::kUndefinedValueRootIndex; |
| 4097 __ LoadRoot(r1, nil_value); |
| 4101 __ cmp(r0, r1); | 4098 __ cmp(r0, r1); |
| 4102 if (is_strict) { | 4099 if (expr->op() == Token::EQ_STRICT) { |
| 4103 Split(eq, if_true, if_false, fall_through); | 4100 Split(eq, if_true, if_false, fall_through); |
| 4104 } else { | 4101 } else { |
| 4102 Heap::RootListIndex other_nil_value = nil == kNullValue ? |
| 4103 Heap::kUndefinedValueRootIndex : |
| 4104 Heap::kNullValueRootIndex; |
| 4105 __ b(eq, if_true); | 4105 __ b(eq, if_true); |
| 4106 __ LoadRoot(r1, Heap::kUndefinedValueRootIndex); | 4106 __ LoadRoot(r1, other_nil_value); |
| 4107 __ cmp(r0, r1); | 4107 __ cmp(r0, r1); |
| 4108 __ b(eq, if_true); | 4108 __ b(eq, if_true); |
| 4109 __ JumpIfSmi(r0, if_false); | 4109 __ JumpIfSmi(r0, if_false); |
| 4110 // It can be an undetectable object. | 4110 // It can be an undetectable object. |
| 4111 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); | 4111 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 4112 __ ldrb(r1, FieldMemOperand(r1, Map::kBitFieldOffset)); | 4112 __ ldrb(r1, FieldMemOperand(r1, Map::kBitFieldOffset)); |
| 4113 __ and_(r1, r1, Operand(1 << Map::kIsUndetectable)); | 4113 __ and_(r1, r1, Operand(1 << Map::kIsUndetectable)); |
| 4114 __ cmp(r1, Operand(1 << Map::kIsUndetectable)); | 4114 __ cmp(r1, Operand(1 << Map::kIsUndetectable)); |
| 4115 Split(eq, if_true, if_false, fall_through); | 4115 Split(eq, if_true, if_false, fall_through); |
| 4116 } | 4116 } |
| 4117 context()->Plug(if_true, if_false); |
| 4117 } | 4118 } |
| 4118 | 4119 |
| 4119 | 4120 |
| 4120 void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) { | 4121 void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) { |
| 4121 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 4122 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 4122 context()->Plug(r0); | 4123 context()->Plug(r0); |
| 4123 } | 4124 } |
| 4124 | 4125 |
| 4125 | 4126 |
| 4126 Register FullCodeGenerator::result_register() { | 4127 Register FullCodeGenerator::result_register() { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4219 *context_length = 0; | 4220 *context_length = 0; |
| 4220 return previous_; | 4221 return previous_; |
| 4221 } | 4222 } |
| 4222 | 4223 |
| 4223 | 4224 |
| 4224 #undef __ | 4225 #undef __ |
| 4225 | 4226 |
| 4226 } } // namespace v8::internal | 4227 } } // namespace v8::internal |
| 4227 | 4228 |
| 4228 #endif // V8_TARGET_ARCH_ARM | 4229 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |