OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 // The variable in the decl always resides in the current context. | 799 // The variable in the decl always resides in the current context. |
800 ASSERT_EQ(0, scope()->ContextChainLength(variable->scope())); | 800 ASSERT_EQ(0, scope()->ContextChainLength(variable->scope())); |
801 if (FLAG_debug_code) { | 801 if (FLAG_debug_code) { |
802 // Check if we have the correct context pointer. | 802 // Check if we have the correct context pointer. |
803 __ mov(ebx, | 803 __ mov(ebx, |
804 CodeGenerator::ContextOperand(esi, Context::FCONTEXT_INDEX)); | 804 CodeGenerator::ContextOperand(esi, Context::FCONTEXT_INDEX)); |
805 __ cmp(ebx, Operand(esi)); | 805 __ cmp(ebx, Operand(esi)); |
806 __ Check(equal, "Unexpected declaration in current context."); | 806 __ Check(equal, "Unexpected declaration in current context."); |
807 } | 807 } |
808 if (mode == Variable::CONST) { | 808 if (mode == Variable::CONST) { |
809 __ mov(eax, Immediate(Factory::the_hole_value())); | 809 __ mov(CodeGenerator::ContextOperand(esi, slot->index()), |
810 __ mov(CodeGenerator::ContextOperand(esi, slot->index()), eax); | 810 Immediate(Factory::the_hole_value())); |
811 // No write barrier since the hole value is in old space. | 811 // No write barrier since the hole value is in old space. |
812 } else if (function != NULL) { | 812 } else if (function != NULL) { |
813 VisitForValue(function, kAccumulator); | 813 VisitForValue(function, kAccumulator); |
814 __ mov(CodeGenerator::ContextOperand(esi, slot->index()), | 814 __ mov(CodeGenerator::ContextOperand(esi, slot->index()), |
815 result_register()); | 815 result_register()); |
816 int offset = Context::SlotOffset(slot->index()); | 816 int offset = Context::SlotOffset(slot->index()); |
817 __ mov(ebx, esi); | 817 __ mov(ebx, esi); |
818 __ RecordWrite(ebx, offset, result_register(), ecx); | 818 __ RecordWrite(ebx, offset, result_register(), ecx); |
819 } | 819 } |
820 break; | 820 break; |
821 | 821 |
822 case Slot::LOOKUP: { | 822 case Slot::LOOKUP: { |
823 __ push(esi); | 823 __ push(esi); |
824 __ push(Immediate(variable->name())); | 824 __ push(Immediate(variable->name())); |
825 // Declaration nodes are always introduced in one of two modes. | 825 // Declaration nodes are always introduced in one of two modes. |
826 ASSERT(mode == Variable::VAR || | 826 ASSERT(mode == Variable::VAR || mode == Variable::CONST); |
827 mode == Variable::CONST); | 827 PropertyAttributes attr = (mode == Variable::VAR) ? NONE : READ_ONLY; |
828 PropertyAttributes attr = | |
829 (mode == Variable::VAR) ? NONE : READ_ONLY; | |
830 __ push(Immediate(Smi::FromInt(attr))); | 828 __ push(Immediate(Smi::FromInt(attr))); |
831 // Push initial value, if any. | 829 // Push initial value, if any. |
832 // Note: For variables we must not push an initial value (such as | 830 // Note: For variables we must not push an initial value (such as |
833 // 'undefined') because we may have a (legal) redeclaration and we | 831 // 'undefined') because we may have a (legal) redeclaration and we |
834 // must not destroy the current value. | 832 // must not destroy the current value. |
835 if (mode == Variable::CONST) { | 833 if (mode == Variable::CONST) { |
836 __ push(Immediate(Factory::the_hole_value())); | 834 __ push(Immediate(Factory::the_hole_value())); |
837 } else if (function != NULL) { | 835 } else if (function != NULL) { |
838 VisitForValue(function, kStack); | 836 VisitForValue(function, kStack); |
839 } else { | 837 } else { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 // Perform the assignment as if via '='. | 1061 // Perform the assignment as if via '='. |
1064 EmitAssignment(stmt->each()); | 1062 EmitAssignment(stmt->each()); |
1065 | 1063 |
1066 // Generate code for the body of the loop. | 1064 // Generate code for the body of the loop. |
1067 Label stack_limit_hit, stack_check_done; | 1065 Label stack_limit_hit, stack_check_done; |
1068 Visit(stmt->body()); | 1066 Visit(stmt->body()); |
1069 | 1067 |
1070 __ StackLimitCheck(&stack_limit_hit); | 1068 __ StackLimitCheck(&stack_limit_hit); |
1071 __ bind(&stack_check_done); | 1069 __ bind(&stack_check_done); |
1072 | 1070 |
1073 // Generate code for the going to the next element by incrementing | 1071 // Generate code for going to the next element by incrementing the |
1074 // the index (smi) stored on top of the stack. | 1072 // index (smi) stored on top of the stack. |
1075 __ bind(loop_statement.continue_target()); | 1073 __ bind(loop_statement.continue_target()); |
1076 __ add(Operand(esp, 0 * kPointerSize), Immediate(Smi::FromInt(1))); | 1074 __ add(Operand(esp, 0 * kPointerSize), Immediate(Smi::FromInt(1))); |
1077 __ jmp(&loop); | 1075 __ jmp(&loop); |
1078 | 1076 |
1079 // Slow case for the stack limit check. | 1077 // Slow case for the stack limit check. |
1080 StackCheckStub stack_check_stub; | 1078 StackCheckStub stack_check_stub; |
1081 __ bind(&stack_limit_hit); | 1079 __ bind(&stack_limit_hit); |
1082 __ CallStub(&stack_check_stub); | 1080 __ CallStub(&stack_check_stub); |
1083 __ jmp(&stack_check_done); | 1081 __ jmp(&stack_check_done); |
1084 | 1082 |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2026 __ j(zero, if_false); | 2024 __ j(zero, if_false); |
2027 __ cmp(eax, Factory::null_value()); | 2025 __ cmp(eax, Factory::null_value()); |
2028 __ j(equal, if_true); | 2026 __ j(equal, if_true); |
2029 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 2027 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
2030 // Undetectable objects behave like undefined when tested with typeof. | 2028 // Undetectable objects behave like undefined when tested with typeof. |
2031 __ movzx_b(ecx, FieldOperand(ebx, Map::kBitFieldOffset)); | 2029 __ movzx_b(ecx, FieldOperand(ebx, Map::kBitFieldOffset)); |
2032 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); | 2030 __ test(ecx, Immediate(1 << Map::kIsUndetectable)); |
2033 __ j(not_zero, if_false); | 2031 __ j(not_zero, if_false); |
2034 __ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | 2032 __ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceTypeOffset)); |
2035 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); | 2033 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); |
2036 __ j(less, if_false); | 2034 __ j(below, if_false); |
2037 __ cmp(ecx, LAST_JS_OBJECT_TYPE); | 2035 __ cmp(ecx, LAST_JS_OBJECT_TYPE); |
2038 __ j(less_equal, if_true); | 2036 __ j(below_equal, if_true); |
2039 __ jmp(if_false); | 2037 __ jmp(if_false); |
2040 | 2038 |
2041 Apply(context_, if_true, if_false); | 2039 Apply(context_, if_true, if_false); |
2042 } | 2040 } |
2043 | 2041 |
2044 | 2042 |
2045 void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) { | 2043 void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) { |
2046 ASSERT(args->length() == 1); | 2044 ASSERT(args->length() == 1); |
2047 | 2045 |
2048 VisitForValue(args->at(0), kAccumulator); | 2046 VisitForValue(args->at(0), kAccumulator); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2220 | 2218 |
2221 // If the object is a smi, we return null. | 2219 // If the object is a smi, we return null. |
2222 __ test(eax, Immediate(kSmiTagMask)); | 2220 __ test(eax, Immediate(kSmiTagMask)); |
2223 __ j(zero, &null); | 2221 __ j(zero, &null); |
2224 | 2222 |
2225 // Check that the object is a JS object but take special care of JS | 2223 // Check that the object is a JS object but take special care of JS |
2226 // functions to make sure they have 'Function' as their class. | 2224 // functions to make sure they have 'Function' as their class. |
2227 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset)); | 2225 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset)); |
2228 __ movzx_b(ebx, FieldOperand(eax, Map::kInstanceTypeOffset)); | 2226 __ movzx_b(ebx, FieldOperand(eax, Map::kInstanceTypeOffset)); |
2229 __ cmp(ebx, FIRST_JS_OBJECT_TYPE); | 2227 __ cmp(ebx, FIRST_JS_OBJECT_TYPE); |
2230 __ j(less, &null); | 2228 __ j(below, &null); |
2231 | 2229 |
2232 // As long as JS_FUNCTION_TYPE is the last instance type and it is | 2230 // As long as JS_FUNCTION_TYPE is the last instance type and it is |
2233 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for | 2231 // right after LAST_JS_OBJECT_TYPE, we can avoid checking for |
2234 // LAST_JS_OBJECT_TYPE. | 2232 // LAST_JS_OBJECT_TYPE. |
2235 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | 2233 ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); |
2236 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); | 2234 ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1); |
2237 __ cmp(ebx, JS_FUNCTION_TYPE); | 2235 __ cmp(ebx, JS_FUNCTION_TYPE); |
2238 __ j(equal, &function); | 2236 __ j(equal, &function); |
2239 | 2237 |
2240 // Check if the constructor in the map is a function. | 2238 // Check if the constructor in the map is a function. |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3240 // And return. | 3238 // And return. |
3241 __ ret(0); | 3239 __ ret(0); |
3242 } | 3240 } |
3243 | 3241 |
3244 | 3242 |
3245 #undef __ | 3243 #undef __ |
3246 | 3244 |
3247 } } // namespace v8::internal | 3245 } } // namespace v8::internal |
3248 | 3246 |
3249 #endif // V8_TARGET_ARCH_IA32 | 3247 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |