| 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 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 __ JumpIfSmi(eax, &convert, Label::kNear); | 913 __ JumpIfSmi(eax, &convert, Label::kNear); |
| 914 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, ecx); | 914 __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, ecx); |
| 915 __ j(above_equal, &done_convert, Label::kNear); | 915 __ j(above_equal, &done_convert, Label::kNear); |
| 916 __ bind(&convert); | 916 __ bind(&convert); |
| 917 __ push(eax); | 917 __ push(eax); |
| 918 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 918 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
| 919 __ bind(&done_convert); | 919 __ bind(&done_convert); |
| 920 __ push(eax); | 920 __ push(eax); |
| 921 increment_stack_height(); | 921 increment_stack_height(); |
| 922 | 922 |
| 923 // Check for proxies. |
| 924 Label call_runtime; |
| 925 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); |
| 926 __ CmpObjectType(eax, LAST_JS_PROXY_TYPE, ecx); |
| 927 __ j(below_equal, &call_runtime); |
| 928 |
| 923 // Check cache validity in generated code. This is a fast case for | 929 // Check cache validity in generated code. This is a fast case for |
| 924 // the JSObject::IsSimpleEnum cache validity checks. If we cannot | 930 // the JSObject::IsSimpleEnum cache validity checks. If we cannot |
| 925 // guarantee cache validity, call the runtime system to check cache | 931 // guarantee cache validity, call the runtime system to check cache |
| 926 // validity or get the property names in a fixed array. | 932 // validity or get the property names in a fixed array. |
| 927 Label next, call_runtime; | 933 Label next; |
| 928 __ mov(ecx, eax); | 934 __ mov(ecx, eax); |
| 929 __ bind(&next); | 935 __ bind(&next); |
| 930 | 936 |
| 931 // Check that there are no elements. Register ecx contains the | 937 // Check that there are no elements. Register ecx contains the |
| 932 // current JS object we've reached through the prototype chain. | 938 // current JS object we've reached through the prototype chain. |
| 933 __ cmp(FieldOperand(ecx, JSObject::kElementsOffset), | 939 __ cmp(FieldOperand(ecx, JSObject::kElementsOffset), |
| 934 isolate()->factory()->empty_fixed_array()); | 940 isolate()->factory()->empty_fixed_array()); |
| 935 __ j(not_equal, &call_runtime); | 941 __ j(not_equal, &call_runtime); |
| 936 | 942 |
| 937 // Check that instance descriptors are not empty so that we can | 943 // Check that instance descriptors are not empty so that we can |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 | 994 |
| 989 // Setup the four remaining stack slots. | 995 // Setup the four remaining stack slots. |
| 990 __ push(eax); // Map. | 996 __ push(eax); // Map. |
| 991 __ push(edx); // Enumeration cache. | 997 __ push(edx); // Enumeration cache. |
| 992 __ mov(eax, FieldOperand(edx, FixedArray::kLengthOffset)); | 998 __ mov(eax, FieldOperand(edx, FixedArray::kLengthOffset)); |
| 993 __ push(eax); // Enumeration cache length (as smi). | 999 __ push(eax); // Enumeration cache length (as smi). |
| 994 __ push(Immediate(Smi::FromInt(0))); // Initial index. | 1000 __ push(Immediate(Smi::FromInt(0))); // Initial index. |
| 995 __ jmp(&loop); | 1001 __ jmp(&loop); |
| 996 | 1002 |
| 997 // We got a fixed array in register eax. Iterate through that. | 1003 // We got a fixed array in register eax. Iterate through that. |
| 1004 Label non_proxy; |
| 998 __ bind(&fixed_array); | 1005 __ bind(&fixed_array); |
| 999 __ push(Immediate(Smi::FromInt(0))); // Map (0) - force slow check. | 1006 __ mov(ebx, Immediate(Smi::FromInt(1))); // Smi indicates slow check |
| 1000 __ push(eax); | 1007 __ mov(ecx, Operand(esp, 0 * kPointerSize)); // Get enumerated object |
| 1008 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); |
| 1009 __ CmpObjectType(ecx, LAST_JS_PROXY_TYPE, ecx); |
| 1010 __ j(above, &non_proxy); |
| 1011 __ mov(ebx, Immediate(Smi::FromInt(0))); // Zero indicates proxy |
| 1012 __ bind(&non_proxy); |
| 1013 __ push(ebx); // Smi |
| 1014 __ push(eax); // Array |
| 1001 __ mov(eax, FieldOperand(eax, FixedArray::kLengthOffset)); | 1015 __ mov(eax, FieldOperand(eax, FixedArray::kLengthOffset)); |
| 1002 __ push(eax); // Fixed array length (as smi). | 1016 __ push(eax); // Fixed array length (as smi). |
| 1003 __ push(Immediate(Smi::FromInt(0))); // Initial index. | 1017 __ push(Immediate(Smi::FromInt(0))); // Initial index. |
| 1004 | 1018 |
| 1005 // 1 ~ The object has already been pushed. | 1019 // 1 ~ The object has already been pushed. |
| 1006 increment_stack_height(ForIn::kElementCount - 1); | 1020 increment_stack_height(ForIn::kElementCount - 1); |
| 1007 // Generate code for doing the condition check. | 1021 // Generate code for doing the condition check. |
| 1008 __ bind(&loop); | 1022 __ bind(&loop); |
| 1009 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index. | 1023 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index. |
| 1010 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length. | 1024 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length. |
| 1011 __ j(above_equal, loop_statement.break_label()); | 1025 __ j(above_equal, loop_statement.break_label()); |
| 1012 | 1026 |
| 1013 // Get the current entry of the array into register ebx. | 1027 // Get the current entry of the array into register ebx. |
| 1014 __ mov(ebx, Operand(esp, 2 * kPointerSize)); | 1028 __ mov(ebx, Operand(esp, 2 * kPointerSize)); |
| 1015 __ mov(ebx, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize)); | 1029 __ mov(ebx, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize)); |
| 1016 | 1030 |
| 1017 // Get the expected map from the stack or a zero map in the | 1031 // Get the expected map from the stack or a smi in the |
| 1018 // permanent slow case into register edx. | 1032 // permanent slow case into register edx. |
| 1019 __ mov(edx, Operand(esp, 3 * kPointerSize)); | 1033 __ mov(edx, Operand(esp, 3 * kPointerSize)); |
| 1020 | 1034 |
| 1021 // Check if the expected map still matches that of the enumerable. | 1035 // Check if the expected map still matches that of the enumerable. |
| 1022 // If not, we have to filter the key. | 1036 // If not, we may have to filter the key. |
| 1023 Label update_each; | 1037 Label update_each; |
| 1024 __ mov(ecx, Operand(esp, 4 * kPointerSize)); | 1038 __ mov(ecx, Operand(esp, 4 * kPointerSize)); |
| 1025 __ cmp(edx, FieldOperand(ecx, HeapObject::kMapOffset)); | 1039 __ cmp(edx, FieldOperand(ecx, HeapObject::kMapOffset)); |
| 1026 __ j(equal, &update_each, Label::kNear); | 1040 __ j(equal, &update_each, Label::kNear); |
| 1027 | 1041 |
| 1042 // For proxies, no filtering is done. |
| 1043 // TODO(rossberg): What if only a prototype is a proxy? Not specified yet. |
| 1044 ASSERT(Smi::FromInt(0) == 0); |
| 1045 __ test(edx, edx); |
| 1046 __ j(zero, &update_each); |
| 1047 |
| 1028 // Convert the entry to a string or null if it isn't a property | 1048 // Convert the entry to a string or null if it isn't a property |
| 1029 // anymore. If the property has been removed while iterating, we | 1049 // anymore. If the property has been removed while iterating, we |
| 1030 // just skip it. | 1050 // just skip it. |
| 1031 __ push(ecx); // Enumerable. | 1051 __ push(ecx); // Enumerable. |
| 1032 __ push(ebx); // Current entry. | 1052 __ push(ebx); // Current entry. |
| 1033 __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION); | 1053 __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION); |
| 1034 __ test(eax, eax); | 1054 __ test(eax, eax); |
| 1035 __ j(equal, loop_statement.continue_label()); | 1055 __ j(equal, loop_statement.continue_label()); |
| 1036 __ mov(ebx, eax); | 1056 __ mov(ebx, eax); |
| 1037 | 1057 |
| (...skipping 3349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4387 *context_length = 0; | 4407 *context_length = 0; |
| 4388 return previous_; | 4408 return previous_; |
| 4389 } | 4409 } |
| 4390 | 4410 |
| 4391 | 4411 |
| 4392 #undef __ | 4412 #undef __ |
| 4393 | 4413 |
| 4394 } } // namespace v8::internal | 4414 } } // namespace v8::internal |
| 4395 | 4415 |
| 4396 #endif // V8_TARGET_ARCH_IA32 | 4416 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |