| 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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 // We know that we have written a function, which is not a smi. | 740 // We know that we have written a function, which is not a smi. |
| 741 __ mov(a1, cp); | 741 __ mov(a1, cp); |
| 742 __ RecordWrite(a1, Operand(offset), a2, result_register()); | 742 __ RecordWrite(a1, Operand(offset), a2, result_register()); |
| 743 } | 743 } |
| 744 break; | 744 break; |
| 745 | 745 |
| 746 case Slot::LOOKUP: { | 746 case Slot::LOOKUP: { |
| 747 __ li(a2, Operand(variable->name())); | 747 __ li(a2, Operand(variable->name())); |
| 748 // Declaration nodes are always introduced in one of two modes. | 748 // Declaration nodes are always introduced in one of two modes. |
| 749 ASSERT(mode == Variable::VAR || | 749 ASSERT(mode == Variable::VAR || |
| 750 mode == Variable::CONST); | 750 mode == Variable::CONST || |
| 751 PropertyAttributes attr = | 751 mode == Variable::LET); |
| 752 (mode == Variable::VAR) ? NONE : READ_ONLY; | 752 PropertyAttributes attr = (mode == Variable::CONST) ? READ_ONLY : NONE; |
| 753 __ li(a1, Operand(Smi::FromInt(attr))); | 753 __ li(a1, Operand(Smi::FromInt(attr))); |
| 754 // Push initial value, if any. | 754 // Push initial value, if any. |
| 755 // Note: For variables we must not push an initial value (such as | 755 // Note: For variables we must not push an initial value (such as |
| 756 // 'undefined') because we may have a (legal) redeclaration and we | 756 // 'undefined') because we may have a (legal) redeclaration and we |
| 757 // must not destroy the current value. | 757 // must not destroy the current value. |
| 758 if (mode == Variable::CONST) { | 758 if (mode == Variable::CONST) { |
| 759 __ LoadRoot(a0, Heap::kTheHoleValueRootIndex); | 759 __ LoadRoot(a0, Heap::kTheHoleValueRootIndex); |
| 760 __ Push(cp, a2, a1, a0); | 760 __ Push(cp, a2, a1, a0); |
| 761 } else if (function != NULL) { | 761 } else if (function != NULL) { |
| 762 __ Push(cp, a2, a1); | 762 __ Push(cp, a2, a1); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 __ Branch(&next_test, ne, v0, Operand(zero_reg)); | 879 __ Branch(&next_test, ne, v0, Operand(zero_reg)); |
| 880 __ Drop(1); // Switch value is no longer needed. | 880 __ Drop(1); // Switch value is no longer needed. |
| 881 __ Branch(clause->body_target()); | 881 __ Branch(clause->body_target()); |
| 882 } | 882 } |
| 883 | 883 |
| 884 // Discard the test value and jump to the default if present, otherwise to | 884 // Discard the test value and jump to the default if present, otherwise to |
| 885 // the end of the statement. | 885 // the end of the statement. |
| 886 __ bind(&next_test); | 886 __ bind(&next_test); |
| 887 __ Drop(1); // Switch value is no longer needed. | 887 __ Drop(1); // Switch value is no longer needed. |
| 888 if (default_clause == NULL) { | 888 if (default_clause == NULL) { |
| 889 __ Branch(nested_statement.break_target()); | 889 __ Branch(nested_statement.break_label()); |
| 890 } else { | 890 } else { |
| 891 __ Branch(default_clause->body_target()); | 891 __ Branch(default_clause->body_target()); |
| 892 } | 892 } |
| 893 | 893 |
| 894 // Compile all the case bodies. | 894 // Compile all the case bodies. |
| 895 for (int i = 0; i < clauses->length(); i++) { | 895 for (int i = 0; i < clauses->length(); i++) { |
| 896 Comment cmnt(masm_, "[ Case body"); | 896 Comment cmnt(masm_, "[ Case body"); |
| 897 CaseClause* clause = clauses->at(i); | 897 CaseClause* clause = clauses->at(i); |
| 898 __ bind(clause->body_target()); | 898 __ bind(clause->body_target()); |
| 899 PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS); | 899 PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS); |
| 900 VisitStatements(clause->statements()); | 900 VisitStatements(clause->statements()); |
| 901 } | 901 } |
| 902 | 902 |
| 903 __ bind(nested_statement.break_target()); | 903 __ bind(nested_statement.break_label()); |
| 904 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 904 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
| 905 } | 905 } |
| 906 | 906 |
| 907 | 907 |
| 908 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { | 908 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
| 909 Comment cmnt(masm_, "[ ForInStatement"); | 909 Comment cmnt(masm_, "[ ForInStatement"); |
| 910 SetStatementPosition(stmt); | 910 SetStatementPosition(stmt); |
| 911 | 911 |
| 912 Label loop, exit; | 912 Label loop, exit; |
| 913 ForIn loop_statement(this, stmt); | 913 ForIn loop_statement(this, stmt); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 __ Push(a1, v0); | 1019 __ Push(a1, v0); |
| 1020 __ lw(a1, FieldMemOperand(v0, FixedArray::kLengthOffset)); | 1020 __ lw(a1, FieldMemOperand(v0, FixedArray::kLengthOffset)); |
| 1021 __ li(a0, Operand(Smi::FromInt(0))); | 1021 __ li(a0, Operand(Smi::FromInt(0))); |
| 1022 __ Push(a1, a0); // Fixed array length (as smi) and initial index. | 1022 __ Push(a1, a0); // Fixed array length (as smi) and initial index. |
| 1023 | 1023 |
| 1024 // Generate code for doing the condition check. | 1024 // Generate code for doing the condition check. |
| 1025 __ bind(&loop); | 1025 __ bind(&loop); |
| 1026 // Load the current count to a0, load the length to a1. | 1026 // Load the current count to a0, load the length to a1. |
| 1027 __ lw(a0, MemOperand(sp, 0 * kPointerSize)); | 1027 __ lw(a0, MemOperand(sp, 0 * kPointerSize)); |
| 1028 __ lw(a1, MemOperand(sp, 1 * kPointerSize)); | 1028 __ lw(a1, MemOperand(sp, 1 * kPointerSize)); |
| 1029 __ Branch(loop_statement.break_target(), hs, a0, Operand(a1)); | 1029 __ Branch(loop_statement.break_label(), hs, a0, Operand(a1)); |
| 1030 | 1030 |
| 1031 // Get the current entry of the array into register a3. | 1031 // Get the current entry of the array into register a3. |
| 1032 __ lw(a2, MemOperand(sp, 2 * kPointerSize)); | 1032 __ lw(a2, MemOperand(sp, 2 * kPointerSize)); |
| 1033 __ Addu(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | 1033 __ Addu(a2, a2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 1034 __ sll(t0, a0, kPointerSizeLog2 - kSmiTagSize); | 1034 __ sll(t0, a0, kPointerSizeLog2 - kSmiTagSize); |
| 1035 __ addu(t0, a2, t0); // Array base + scaled (smi) index. | 1035 __ addu(t0, a2, t0); // Array base + scaled (smi) index. |
| 1036 __ lw(a3, MemOperand(t0)); // Current entry. | 1036 __ lw(a3, MemOperand(t0)); // Current entry. |
| 1037 | 1037 |
| 1038 // Get the expected map from the stack or a zero map in the | 1038 // Get the expected map from the stack or a zero map in the |
| 1039 // permanent slow case into register a2. | 1039 // permanent slow case into register a2. |
| 1040 __ lw(a2, MemOperand(sp, 3 * kPointerSize)); | 1040 __ lw(a2, MemOperand(sp, 3 * kPointerSize)); |
| 1041 | 1041 |
| 1042 // Check if the expected map still matches that of the enumerable. | 1042 // Check if the expected map still matches that of the enumerable. |
| 1043 // If not, we have to filter the key. | 1043 // If not, we have to filter the key. |
| 1044 Label update_each; | 1044 Label update_each; |
| 1045 __ lw(a1, MemOperand(sp, 4 * kPointerSize)); | 1045 __ lw(a1, MemOperand(sp, 4 * kPointerSize)); |
| 1046 __ lw(t0, FieldMemOperand(a1, HeapObject::kMapOffset)); | 1046 __ lw(t0, FieldMemOperand(a1, HeapObject::kMapOffset)); |
| 1047 __ Branch(&update_each, eq, t0, Operand(a2)); | 1047 __ Branch(&update_each, eq, t0, Operand(a2)); |
| 1048 | 1048 |
| 1049 // Convert the entry to a string or (smi) 0 if it isn't a property | 1049 // Convert the entry to a string or (smi) 0 if it isn't a property |
| 1050 // any more. If the property has been removed while iterating, we | 1050 // any more. If the property has been removed while iterating, we |
| 1051 // just skip it. | 1051 // just skip it. |
| 1052 __ push(a1); // Enumerable. | 1052 __ push(a1); // Enumerable. |
| 1053 __ push(a3); // Current entry. | 1053 __ push(a3); // Current entry. |
| 1054 __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION); | 1054 __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION); |
| 1055 __ mov(a3, result_register()); | 1055 __ mov(a3, result_register()); |
| 1056 __ Branch(loop_statement.continue_target(), eq, a3, Operand(zero_reg)); | 1056 __ Branch(loop_statement.continue_label(), eq, a3, Operand(zero_reg)); |
| 1057 | 1057 |
| 1058 // Update the 'each' property or variable from the possibly filtered | 1058 // Update the 'each' property or variable from the possibly filtered |
| 1059 // entry in register a3. | 1059 // entry in register a3. |
| 1060 __ bind(&update_each); | 1060 __ bind(&update_each); |
| 1061 __ mov(result_register(), a3); | 1061 __ mov(result_register(), a3); |
| 1062 // Perform the assignment as if via '='. | 1062 // Perform the assignment as if via '='. |
| 1063 { EffectContext context(this); | 1063 { EffectContext context(this); |
| 1064 EmitAssignment(stmt->each(), stmt->AssignmentId()); | 1064 EmitAssignment(stmt->each(), stmt->AssignmentId()); |
| 1065 } | 1065 } |
| 1066 | 1066 |
| 1067 // Generate code for the body of the loop. | 1067 // Generate code for the body of the loop. |
| 1068 Visit(stmt->body()); | 1068 Visit(stmt->body()); |
| 1069 | 1069 |
| 1070 // Generate code for the going to the next element by incrementing | 1070 // Generate code for the going to the next element by incrementing |
| 1071 // the index (smi) stored on top of the stack. | 1071 // the index (smi) stored on top of the stack. |
| 1072 __ bind(loop_statement.continue_target()); | 1072 __ bind(loop_statement.continue_label()); |
| 1073 __ pop(a0); | 1073 __ pop(a0); |
| 1074 __ Addu(a0, a0, Operand(Smi::FromInt(1))); | 1074 __ Addu(a0, a0, Operand(Smi::FromInt(1))); |
| 1075 __ push(a0); | 1075 __ push(a0); |
| 1076 | 1076 |
| 1077 EmitStackCheck(stmt); | 1077 EmitStackCheck(stmt); |
| 1078 __ Branch(&loop); | 1078 __ Branch(&loop); |
| 1079 | 1079 |
| 1080 // Remove the pointers stored on the stack. | 1080 // Remove the pointers stored on the stack. |
| 1081 __ bind(loop_statement.break_target()); | 1081 __ bind(loop_statement.break_label()); |
| 1082 __ Drop(5); | 1082 __ Drop(5); |
| 1083 | 1083 |
| 1084 // Exit and decrement the loop depth. | 1084 // Exit and decrement the loop depth. |
| 1085 __ bind(&exit); | 1085 __ bind(&exit); |
| 1086 decrement_loop_depth(); | 1086 decrement_loop_depth(); |
| 1087 } | 1087 } |
| 1088 | 1088 |
| 1089 | 1089 |
| 1090 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, | 1090 void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
| 1091 bool pretenure) { | 1091 bool pretenure) { |
| (...skipping 2953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4045 __ Branch(if_false, ge, a1, Operand(FIRST_NONSTRING_TYPE)); | 4045 __ Branch(if_false, ge, a1, Operand(FIRST_NONSTRING_TYPE)); |
| 4046 __ lbu(a1, FieldMemOperand(v0, Map::kBitFieldOffset)); | 4046 __ lbu(a1, FieldMemOperand(v0, Map::kBitFieldOffset)); |
| 4047 __ And(a1, a1, Operand(1 << Map::kIsUndetectable)); | 4047 __ And(a1, a1, Operand(1 << Map::kIsUndetectable)); |
| 4048 Split(eq, a1, Operand(zero_reg), | 4048 Split(eq, a1, Operand(zero_reg), |
| 4049 if_true, if_false, fall_through); | 4049 if_true, if_false, fall_through); |
| 4050 } else if (check->Equals(isolate()->heap()->boolean_symbol())) { | 4050 } else if (check->Equals(isolate()->heap()->boolean_symbol())) { |
| 4051 __ LoadRoot(at, Heap::kTrueValueRootIndex); | 4051 __ LoadRoot(at, Heap::kTrueValueRootIndex); |
| 4052 __ Branch(if_true, eq, v0, Operand(at)); | 4052 __ Branch(if_true, eq, v0, Operand(at)); |
| 4053 __ LoadRoot(at, Heap::kFalseValueRootIndex); | 4053 __ LoadRoot(at, Heap::kFalseValueRootIndex); |
| 4054 Split(eq, v0, Operand(at), if_true, if_false, fall_through); | 4054 Split(eq, v0, Operand(at), if_true, if_false, fall_through); |
| 4055 } else if (FLAG_harmony_typeof && |
| 4056 check->Equals(isolate()->heap()->null_symbol())) { |
| 4057 __ LoadRoot(at, Heap::kNullValueRootIndex); |
| 4058 Split(eq, v0, Operand(at), if_true, if_false, fall_through); |
| 4055 } else if (check->Equals(isolate()->heap()->undefined_symbol())) { | 4059 } else if (check->Equals(isolate()->heap()->undefined_symbol())) { |
| 4056 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 4060 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
| 4057 __ Branch(if_true, eq, v0, Operand(at)); | 4061 __ Branch(if_true, eq, v0, Operand(at)); |
| 4058 __ JumpIfSmi(v0, if_false); | 4062 __ JumpIfSmi(v0, if_false); |
| 4059 // Check for undetectable objects => true. | 4063 // Check for undetectable objects => true. |
| 4060 __ lw(v0, FieldMemOperand(v0, HeapObject::kMapOffset)); | 4064 __ lw(v0, FieldMemOperand(v0, HeapObject::kMapOffset)); |
| 4061 __ lbu(a1, FieldMemOperand(v0, Map::kBitFieldOffset)); | 4065 __ lbu(a1, FieldMemOperand(v0, Map::kBitFieldOffset)); |
| 4062 __ And(a1, a1, Operand(1 << Map::kIsUndetectable)); | 4066 __ And(a1, a1, Operand(1 << Map::kIsUndetectable)); |
| 4063 Split(ne, a1, Operand(zero_reg), if_true, if_false, fall_through); | 4067 Split(ne, a1, Operand(zero_reg), if_true, if_false, fall_through); |
| 4064 } else if (check->Equals(isolate()->heap()->function_symbol())) { | 4068 } else if (check->Equals(isolate()->heap()->function_symbol())) { |
| 4065 __ JumpIfSmi(v0, if_false); | 4069 __ JumpIfSmi(v0, if_false); |
| 4066 __ GetObjectType(v0, a1, v0); // Leave map in a1. | 4070 __ GetObjectType(v0, a1, v0); // Leave map in a1. |
| 4067 Split(ge, v0, Operand(FIRST_CALLABLE_SPEC_OBJECT_TYPE), | 4071 Split(ge, v0, Operand(FIRST_CALLABLE_SPEC_OBJECT_TYPE), |
| 4068 if_true, if_false, fall_through); | 4072 if_true, if_false, fall_through); |
| 4069 | 4073 |
| 4070 } else if (check->Equals(isolate()->heap()->object_symbol())) { | 4074 } else if (check->Equals(isolate()->heap()->object_symbol())) { |
| 4071 __ JumpIfSmi(v0, if_false); | 4075 __ JumpIfSmi(v0, if_false); |
| 4072 __ LoadRoot(at, Heap::kNullValueRootIndex); | 4076 if (!FLAG_harmony_typeof) { |
| 4073 __ Branch(if_true, eq, v0, Operand(at)); | 4077 __ LoadRoot(at, Heap::kNullValueRootIndex); |
| 4078 __ Branch(if_true, eq, v0, Operand(at)); |
| 4079 } |
| 4074 // Check for JS objects => true. | 4080 // Check for JS objects => true. |
| 4075 __ GetObjectType(v0, v0, a1); | 4081 __ GetObjectType(v0, v0, a1); |
| 4076 __ Branch(if_false, lt, a1, Operand(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); | 4082 __ Branch(if_false, lt, a1, Operand(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
| 4077 __ lbu(a1, FieldMemOperand(v0, Map::kInstanceTypeOffset)); | 4083 __ lbu(a1, FieldMemOperand(v0, Map::kInstanceTypeOffset)); |
| 4078 __ Branch(if_false, gt, a1, Operand(LAST_NONCALLABLE_SPEC_OBJECT_TYPE)); | 4084 __ Branch(if_false, gt, a1, Operand(LAST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
| 4079 // Check for undetectable objects => false. | 4085 // Check for undetectable objects => false. |
| 4080 __ lbu(a1, FieldMemOperand(v0, Map::kBitFieldOffset)); | 4086 __ lbu(a1, FieldMemOperand(v0, Map::kBitFieldOffset)); |
| 4081 __ And(a1, a1, Operand(1 << Map::kIsUndetectable)); | 4087 __ And(a1, a1, Operand(1 << Map::kIsUndetectable)); |
| 4082 Split(eq, a1, Operand(zero_reg), if_true, if_false, fall_through); | 4088 Split(eq, a1, Operand(zero_reg), if_true, if_false, fall_through); |
| 4083 } else { | 4089 } else { |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4312 __ Addu(at, a1, Operand(masm_->CodeObject())); | 4318 __ Addu(at, a1, Operand(masm_->CodeObject())); |
| 4313 __ Jump(at); | 4319 __ Jump(at); |
| 4314 } | 4320 } |
| 4315 | 4321 |
| 4316 | 4322 |
| 4317 #undef __ | 4323 #undef __ |
| 4318 | 4324 |
| 4319 } } // namespace v8::internal | 4325 } } // namespace v8::internal |
| 4320 | 4326 |
| 4321 #endif // V8_TARGET_ARCH_MIPS | 4327 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |