| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 // arguments passed in because it is constant. At some point we | 1045 // arguments passed in because it is constant. At some point we |
| 1046 // should remove this need and make the runtime routine entry code | 1046 // should remove this need and make the runtime routine entry code |
| 1047 // smarter. | 1047 // smarter. |
| 1048 Set(eax, Immediate(num_arguments)); | 1048 Set(eax, Immediate(num_arguments)); |
| 1049 mov(ebx, Immediate(ExternalReference(f))); | 1049 mov(ebx, Immediate(ExternalReference(f))); |
| 1050 CEntryStub ces(1); | 1050 CEntryStub ces(1); |
| 1051 CallStub(&ces); | 1051 CallStub(&ces); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 | 1054 |
| 1055 void MacroAssembler::CallExternalReference(ExternalReference ref, | |
| 1056 int num_arguments) { | |
| 1057 mov(eax, Immediate(num_arguments)); | |
| 1058 mov(ebx, Immediate(ref)); | |
| 1059 | |
| 1060 CEntryStub stub(1); | |
| 1061 CallStub(&stub); | |
| 1062 } | |
| 1063 | |
| 1064 | |
| 1065 Object* MacroAssembler::TryCallRuntime(Runtime::Function* f, | 1055 Object* MacroAssembler::TryCallRuntime(Runtime::Function* f, |
| 1066 int num_arguments) { | 1056 int num_arguments) { |
| 1067 if (f->nargs >= 0 && f->nargs != num_arguments) { | 1057 if (f->nargs >= 0 && f->nargs != num_arguments) { |
| 1068 IllegalOperation(num_arguments); | 1058 IllegalOperation(num_arguments); |
| 1069 // Since we did not call the stub, there was no allocation failure. | 1059 // Since we did not call the stub, there was no allocation failure. |
| 1070 // Return some non-failure object. | 1060 // Return some non-failure object. |
| 1071 return Heap::undefined_value(); | 1061 return Heap::undefined_value(); |
| 1072 } | 1062 } |
| 1073 | 1063 |
| 1074 // TODO(1236192): Most runtime routines don't need the number of | 1064 // TODO(1236192): Most runtime routines don't need the number of |
| 1075 // arguments passed in because it is constant. At some point we | 1065 // arguments passed in because it is constant. At some point we |
| 1076 // should remove this need and make the runtime routine entry code | 1066 // should remove this need and make the runtime routine entry code |
| 1077 // smarter. | 1067 // smarter. |
| 1078 Set(eax, Immediate(num_arguments)); | 1068 Set(eax, Immediate(num_arguments)); |
| 1079 mov(ebx, Immediate(ExternalReference(f))); | 1069 mov(ebx, Immediate(ExternalReference(f))); |
| 1080 CEntryStub ces(1); | 1070 CEntryStub ces(1); |
| 1081 return TryCallStub(&ces); | 1071 return TryCallStub(&ces); |
| 1082 } | 1072 } |
| 1083 | 1073 |
| 1084 | 1074 |
| 1075 void MacroAssembler::CallExternalReference(ExternalReference ref, |
| 1076 int num_arguments) { |
| 1077 mov(eax, Immediate(num_arguments)); |
| 1078 mov(ebx, Immediate(ref)); |
| 1079 |
| 1080 CEntryStub stub(1); |
| 1081 CallStub(&stub); |
| 1082 } |
| 1083 |
| 1084 |
| 1085 void MacroAssembler::TailCallExternalReference(const ExternalReference& ext, | 1085 void MacroAssembler::TailCallExternalReference(const ExternalReference& ext, |
| 1086 int num_arguments, | 1086 int num_arguments, |
| 1087 int result_size) { | 1087 int result_size) { |
| 1088 // TODO(1236192): Most runtime routines don't need the number of | 1088 // TODO(1236192): Most runtime routines don't need the number of |
| 1089 // arguments passed in because it is constant. At some point we | 1089 // arguments passed in because it is constant. At some point we |
| 1090 // should remove this need and make the runtime routine entry code | 1090 // should remove this need and make the runtime routine entry code |
| 1091 // smarter. | 1091 // smarter. |
| 1092 Set(eax, Immediate(num_arguments)); | 1092 Set(eax, Immediate(num_arguments)); |
| 1093 JumpToExternalReference(ext); | 1093 JumpToExternalReference(ext); |
| 1094 } | 1094 } |
| 1095 | 1095 |
| 1096 | 1096 |
| 1097 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid, | 1097 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid, |
| 1098 int num_arguments, | 1098 int num_arguments, |
| 1099 int result_size) { | 1099 int result_size) { |
| 1100 TailCallExternalReference(ExternalReference(fid), num_arguments, result_size); | 1100 TailCallExternalReference(ExternalReference(fid), num_arguments, result_size); |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 | 1103 |
| 1104 void MacroAssembler::PushHandleScope(Register scratch) { | 1104 void MacroAssembler::PushHandleScope(Register scratch) { |
| 1105 // Push the number of extensions, smi-tagged so the gc will ignore it. | 1105 // Push the number of extensions, smi-tagged so the gc will ignore it. |
| 1106 ExternalReference extensions_address = | 1106 ExternalReference extensions_address = |
| 1107 ExternalReference::handle_scope_extensions_address(); | 1107 ExternalReference::handle_scope_extensions_address(); |
| 1108 mov(scratch, Operand::StaticVariable(extensions_address)); | 1108 mov(scratch, Operand::StaticVariable(extensions_address)); |
| 1109 ASSERT_EQ(0, kSmiTag); | 1109 SmiTag(scratch); |
| 1110 shl(scratch, kSmiTagSize); | |
| 1111 push(scratch); | 1110 push(scratch); |
| 1112 mov(Operand::StaticVariable(extensions_address), Immediate(0)); | 1111 mov(Operand::StaticVariable(extensions_address), Immediate(0)); |
| 1113 // Push next and limit pointers which will be wordsize aligned and | 1112 // Push next and limit pointers which will be wordsize aligned and |
| 1114 // hence automatically smi tagged. | 1113 // hence automatically smi tagged. |
| 1115 ExternalReference next_address = | 1114 ExternalReference next_address = |
| 1116 ExternalReference::handle_scope_next_address(); | 1115 ExternalReference::handle_scope_next_address(); |
| 1117 push(Operand::StaticVariable(next_address)); | 1116 push(Operand::StaticVariable(next_address)); |
| 1118 ExternalReference limit_address = | 1117 ExternalReference limit_address = |
| 1119 ExternalReference::handle_scope_limit_address(); | 1118 ExternalReference::handle_scope_limit_address(); |
| 1120 push(Operand::StaticVariable(limit_address)); | 1119 push(Operand::StaticVariable(limit_address)); |
| 1121 } | 1120 } |
| 1122 | 1121 |
| 1123 | 1122 |
| 1124 Object* MacroAssembler::PopHandleScopeHelper(Register saved, | 1123 Object* MacroAssembler::PopHandleScopeHelper(Register saved, |
| 1125 Register scratch, | 1124 Register scratch, |
| 1126 bool gc_allowed) { | 1125 bool gc_allowed) { |
| 1127 Object* result = NULL; | 1126 Object* result = NULL; |
| 1128 ExternalReference extensions_address = | 1127 ExternalReference extensions_address = |
| 1129 ExternalReference::handle_scope_extensions_address(); | 1128 ExternalReference::handle_scope_extensions_address(); |
| 1130 Label write_back; | 1129 Label write_back; |
| 1131 mov(scratch, Operand::StaticVariable(extensions_address)); | 1130 mov(scratch, Operand::StaticVariable(extensions_address)); |
| 1132 cmp(Operand(scratch), Immediate(0)); | 1131 cmp(Operand(scratch), Immediate(0)); |
| 1133 j(equal, &write_back); | 1132 j(equal, &write_back); |
| 1134 // Calling a runtime function messes with registers so we save and | 1133 push(saved); |
| 1135 // restore any one we're asked not to change | |
| 1136 if (saved.is_valid()) push(saved); | |
| 1137 if (gc_allowed) { | 1134 if (gc_allowed) { |
| 1138 CallRuntime(Runtime::kDeleteHandleScopeExtensions, 0); | 1135 CallRuntime(Runtime::kDeleteHandleScopeExtensions, 0); |
| 1139 } else { | 1136 } else { |
| 1140 result = TryCallRuntime(Runtime::kDeleteHandleScopeExtensions, 0); | 1137 result = TryCallRuntime(Runtime::kDeleteHandleScopeExtensions, 0); |
| 1141 if (result->IsFailure()) return result; | 1138 if (result->IsFailure()) return result; |
| 1142 } | 1139 } |
| 1143 if (saved.is_valid()) pop(saved); | 1140 pop(saved); |
| 1144 | 1141 |
| 1145 bind(&write_back); | 1142 bind(&write_back); |
| 1146 ExternalReference limit_address = | 1143 ExternalReference limit_address = |
| 1147 ExternalReference::handle_scope_limit_address(); | 1144 ExternalReference::handle_scope_limit_address(); |
| 1148 pop(Operand::StaticVariable(limit_address)); | 1145 pop(Operand::StaticVariable(limit_address)); |
| 1149 ExternalReference next_address = | 1146 ExternalReference next_address = |
| 1150 ExternalReference::handle_scope_next_address(); | 1147 ExternalReference::handle_scope_next_address(); |
| 1151 pop(Operand::StaticVariable(next_address)); | 1148 pop(Operand::StaticVariable(next_address)); |
| 1152 pop(scratch); | 1149 pop(scratch); |
| 1153 shr(scratch, kSmiTagSize); | 1150 SmiUntag(scratch); |
| 1154 mov(Operand::StaticVariable(extensions_address), scratch); | 1151 mov(Operand::StaticVariable(extensions_address), scratch); |
| 1155 | 1152 |
| 1156 return result; | 1153 return result; |
| 1157 } | 1154 } |
| 1158 | 1155 |
| 1159 | 1156 |
| 1160 void MacroAssembler::PopHandleScope(Register saved, Register scratch) { | 1157 void MacroAssembler::PopHandleScope(Register saved, Register scratch) { |
| 1161 PopHandleScopeHelper(saved, scratch, true); | 1158 PopHandleScopeHelper(saved, scratch, true); |
| 1162 } | 1159 } |
| 1163 | 1160 |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1601 | 1598 |
| 1602 // Check that the code was patched as expected. | 1599 // Check that the code was patched as expected. |
| 1603 ASSERT(masm_.pc_ == address_ + size_); | 1600 ASSERT(masm_.pc_ == address_ + size_); |
| 1604 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 1601 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 1605 } | 1602 } |
| 1606 | 1603 |
| 1607 | 1604 |
| 1608 } } // namespace v8::internal | 1605 } } // namespace v8::internal |
| 1609 | 1606 |
| 1610 #endif // V8_TARGET_ARCH_IA32 | 1607 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |