| 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 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 __ j(not_equal, &next_test); | 868 __ j(not_equal, &next_test); |
| 869 __ Drop(1); // Switch value is no longer needed. | 869 __ Drop(1); // Switch value is no longer needed. |
| 870 __ jmp(clause->body_target()); | 870 __ jmp(clause->body_target()); |
| 871 } | 871 } |
| 872 | 872 |
| 873 // Discard the test value and jump to the default if present, otherwise to | 873 // Discard the test value and jump to the default if present, otherwise to |
| 874 // the end of the statement. | 874 // the end of the statement. |
| 875 __ bind(&next_test); | 875 __ bind(&next_test); |
| 876 __ Drop(1); // Switch value is no longer needed. | 876 __ Drop(1); // Switch value is no longer needed. |
| 877 if (default_clause == NULL) { | 877 if (default_clause == NULL) { |
| 878 __ jmp(nested_statement.break_target()); | 878 __ jmp(nested_statement.break_label()); |
| 879 } else { | 879 } else { |
| 880 __ jmp(default_clause->body_target()); | 880 __ jmp(default_clause->body_target()); |
| 881 } | 881 } |
| 882 | 882 |
| 883 set_stack_height(switch_clause_stack_height); | 883 set_stack_height(switch_clause_stack_height); |
| 884 // Compile all the case bodies. | 884 // Compile all the case bodies. |
| 885 for (int i = 0; i < clauses->length(); i++) { | 885 for (int i = 0; i < clauses->length(); i++) { |
| 886 Comment cmnt(masm_, "[ Case body"); | 886 Comment cmnt(masm_, "[ Case body"); |
| 887 CaseClause* clause = clauses->at(i); | 887 CaseClause* clause = clauses->at(i); |
| 888 __ bind(clause->body_target()); | 888 __ bind(clause->body_target()); |
| 889 PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS); | 889 PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS); |
| 890 VisitStatements(clause->statements()); | 890 VisitStatements(clause->statements()); |
| 891 } | 891 } |
| 892 | 892 |
| 893 __ bind(nested_statement.break_target()); | 893 __ bind(nested_statement.break_label()); |
| 894 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 894 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
| 895 } | 895 } |
| 896 | 896 |
| 897 | 897 |
| 898 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { | 898 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
| 899 Comment cmnt(masm_, "[ ForInStatement"); | 899 Comment cmnt(masm_, "[ ForInStatement"); |
| 900 SetStatementPosition(stmt); | 900 SetStatementPosition(stmt); |
| 901 | 901 |
| 902 Label loop, exit; | 902 Label loop, exit; |
| 903 ForIn loop_statement(this, stmt); | 903 ForIn loop_statement(this, stmt); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 __ jmp(&loop); | 999 __ jmp(&loop); |
| 1000 | 1000 |
| 1001 // We got a fixed array in register eax. Iterate through that. | 1001 // We got a fixed array in register eax. Iterate through that. |
| 1002 __ bind(&fixed_array); | 1002 __ bind(&fixed_array); |
| 1003 __ push(Immediate(Smi::FromInt(0))); // Map (0) - force slow check. | 1003 __ push(Immediate(Smi::FromInt(0))); // Map (0) - force slow check. |
| 1004 __ push(eax); | 1004 __ push(eax); |
| 1005 __ mov(eax, FieldOperand(eax, FixedArray::kLengthOffset)); | 1005 __ mov(eax, FieldOperand(eax, FixedArray::kLengthOffset)); |
| 1006 __ push(eax); // Fixed array length (as smi). | 1006 __ push(eax); // Fixed array length (as smi). |
| 1007 __ push(Immediate(Smi::FromInt(0))); // Initial index. | 1007 __ push(Immediate(Smi::FromInt(0))); // Initial index. |
| 1008 | 1008 |
| 1009 increment_stack_height(4); | 1009 // 1 ~ The object has already been pushed. |
| 1010 increment_stack_height(ForIn::kElementCount - 1); |
| 1010 // Generate code for doing the condition check. | 1011 // Generate code for doing the condition check. |
| 1011 __ bind(&loop); | 1012 __ bind(&loop); |
| 1012 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index. | 1013 __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index. |
| 1013 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length. | 1014 __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length. |
| 1014 __ j(above_equal, loop_statement.break_target()); | 1015 __ j(above_equal, loop_statement.break_label()); |
| 1015 | 1016 |
| 1016 // Get the current entry of the array into register ebx. | 1017 // Get the current entry of the array into register ebx. |
| 1017 __ mov(ebx, Operand(esp, 2 * kPointerSize)); | 1018 __ mov(ebx, Operand(esp, 2 * kPointerSize)); |
| 1018 __ mov(ebx, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize)); | 1019 __ mov(ebx, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize)); |
| 1019 | 1020 |
| 1020 // Get the expected map from the stack or a zero map in the | 1021 // Get the expected map from the stack or a zero map in the |
| 1021 // permanent slow case into register edx. | 1022 // permanent slow case into register edx. |
| 1022 __ mov(edx, Operand(esp, 3 * kPointerSize)); | 1023 __ mov(edx, Operand(esp, 3 * kPointerSize)); |
| 1023 | 1024 |
| 1024 // Check if the expected map still matches that of the enumerable. | 1025 // Check if the expected map still matches that of the enumerable. |
| 1025 // If not, we have to filter the key. | 1026 // If not, we have to filter the key. |
| 1026 Label update_each; | 1027 Label update_each; |
| 1027 __ mov(ecx, Operand(esp, 4 * kPointerSize)); | 1028 __ mov(ecx, Operand(esp, 4 * kPointerSize)); |
| 1028 __ cmp(edx, FieldOperand(ecx, HeapObject::kMapOffset)); | 1029 __ cmp(edx, FieldOperand(ecx, HeapObject::kMapOffset)); |
| 1029 __ j(equal, &update_each, Label::kNear); | 1030 __ j(equal, &update_each, Label::kNear); |
| 1030 | 1031 |
| 1031 // Convert the entry to a string or null if it isn't a property | 1032 // Convert the entry to a string or null if it isn't a property |
| 1032 // anymore. If the property has been removed while iterating, we | 1033 // anymore. If the property has been removed while iterating, we |
| 1033 // just skip it. | 1034 // just skip it. |
| 1034 __ push(ecx); // Enumerable. | 1035 __ push(ecx); // Enumerable. |
| 1035 __ push(ebx); // Current entry. | 1036 __ push(ebx); // Current entry. |
| 1036 __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION); | 1037 __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION); |
| 1037 __ test(eax, Operand(eax)); | 1038 __ test(eax, Operand(eax)); |
| 1038 __ j(equal, loop_statement.continue_target()); | 1039 __ j(equal, loop_statement.continue_label()); |
| 1039 __ mov(ebx, Operand(eax)); | 1040 __ mov(ebx, Operand(eax)); |
| 1040 | 1041 |
| 1041 // Update the 'each' property or variable from the possibly filtered | 1042 // Update the 'each' property or variable from the possibly filtered |
| 1042 // entry in register ebx. | 1043 // entry in register ebx. |
| 1043 __ bind(&update_each); | 1044 __ bind(&update_each); |
| 1044 __ mov(result_register(), ebx); | 1045 __ mov(result_register(), ebx); |
| 1045 // Perform the assignment as if via '='. | 1046 // Perform the assignment as if via '='. |
| 1046 { EffectContext context(this); | 1047 { EffectContext context(this); |
| 1047 EmitAssignment(stmt->each(), stmt->AssignmentId()); | 1048 EmitAssignment(stmt->each(), stmt->AssignmentId()); |
| 1048 } | 1049 } |
| 1049 | 1050 |
| 1050 // Generate code for the body of the loop. | 1051 // Generate code for the body of the loop. |
| 1051 Visit(stmt->body()); | 1052 Visit(stmt->body()); |
| 1052 | 1053 |
| 1053 // Generate code for going to the next element by incrementing the | 1054 // Generate code for going to the next element by incrementing the |
| 1054 // index (smi) stored on top of the stack. | 1055 // index (smi) stored on top of the stack. |
| 1055 __ bind(loop_statement.continue_target()); | 1056 __ bind(loop_statement.continue_label()); |
| 1056 __ add(Operand(esp, 0 * kPointerSize), Immediate(Smi::FromInt(1))); | 1057 __ add(Operand(esp, 0 * kPointerSize), Immediate(Smi::FromInt(1))); |
| 1057 | 1058 |
| 1058 EmitStackCheck(stmt); | 1059 EmitStackCheck(stmt); |
| 1059 __ jmp(&loop); | 1060 __ jmp(&loop); |
| 1060 | 1061 |
| 1061 // Remove the pointers stored on the stack. | 1062 // Remove the pointers stored on the stack. |
| 1062 __ bind(loop_statement.break_target()); | 1063 __ bind(loop_statement.break_label()); |
| 1063 __ add(Operand(esp), Immediate(5 * kPointerSize)); | 1064 __ add(Operand(esp), Immediate(5 * kPointerSize)); |
| 1064 | 1065 |
| 1065 decrement_stack_height(5); | 1066 decrement_stack_height(ForIn::kElementCount); |
| 1066 // Exit and decrement the loop depth. | 1067 // Exit and decrement the loop depth. |
| 1067 __ bind(&exit); | 1068 __ bind(&exit); |
| 1068 decrement_loop_depth(); | 1069 decrement_loop_depth(); |
| 1069 } | 1070 } |
| 1070 | 1071 |
| 1071 | 1072 |
| 1072 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, | 1073 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
| 1073 bool pretenure) { | 1074 bool pretenure) { |
| 1074 // Use the fast case closure allocation code that allocates in new | 1075 // Use the fast case closure allocation code that allocates in new |
| 1075 // space for nested functions that don't need literals cloning. If | 1076 // space for nested functions that don't need literals cloning. If |
| (...skipping 3295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4371 __ add(Operand(edx), Immediate(masm_->CodeObject())); | 4372 __ add(Operand(edx), Immediate(masm_->CodeObject())); |
| 4372 __ jmp(Operand(edx)); | 4373 __ jmp(Operand(edx)); |
| 4373 } | 4374 } |
| 4374 | 4375 |
| 4375 | 4376 |
| 4376 #undef __ | 4377 #undef __ |
| 4377 | 4378 |
| 4378 } } // namespace v8::internal | 4379 } } // namespace v8::internal |
| 4379 | 4380 |
| 4380 #endif // V8_TARGET_ARCH_IA32 | 4381 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |