Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 4695003: Removing redundant stubs for API functions. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 int result_size) { 1103 int result_size) {
1104 // TODO(1236192): Most runtime routines don't need the number of 1104 // TODO(1236192): Most runtime routines don't need the number of
1105 // arguments passed in because it is constant. At some point we 1105 // arguments passed in because it is constant. At some point we
1106 // should remove this need and make the runtime routine entry code 1106 // should remove this need and make the runtime routine entry code
1107 // smarter. 1107 // smarter.
1108 Set(eax, Immediate(num_arguments)); 1108 Set(eax, Immediate(num_arguments));
1109 JumpToExternalReference(ext); 1109 JumpToExternalReference(ext);
1110 } 1110 }
1111 1111
1112 1112
1113 MaybeObject* MacroAssembler::TryTailCallExternalReference(
1114 const ExternalReference& ext, int num_arguments, int result_size) {
1115 // TODO(1236192): Most runtime routines don't need the number of
1116 // arguments passed in because it is constant. At some point we
1117 // should remove this need and make the runtime routine entry code
1118 // smarter.
1119 Set(eax, Immediate(num_arguments));
1120 return TryJumpToExternalReference(ext);
1121 }
1122
1123
1113 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid, 1124 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid,
1114 int num_arguments, 1125 int num_arguments,
1115 int result_size) { 1126 int result_size) {
1116 TailCallExternalReference(ExternalReference(fid), num_arguments, result_size); 1127 TailCallExternalReference(ExternalReference(fid), num_arguments, result_size);
1117 } 1128 }
1118 1129
1119 1130
1131 MaybeObject* MacroAssembler::TryTailCallRuntime(Runtime::FunctionId fid,
1132 int num_arguments,
1133 int result_size) {
1134 return TryTailCallExternalReference(
1135 ExternalReference(fid), num_arguments, result_size);
1136 }
1137
1138
1120 // If true, a Handle<T> passed by value is passed and returned by 1139 // If true, a Handle<T> passed by value is passed and returned by
1121 // using the location_ field directly. If false, it is passed and 1140 // using the location_ field directly. If false, it is passed and
1122 // returned as a pointer to a handle. 1141 // returned as a pointer to a handle.
1123 #ifdef USING_BSD_ABI 1142 #ifdef USING_BSD_ABI
1124 static const bool kPassHandlesDirectly = true; 1143 static const bool kPassHandlesDirectly = true;
1125 #else 1144 #else
1126 static const bool kPassHandlesDirectly = false; 1145 static const bool kPassHandlesDirectly = false;
1127 #endif 1146 #endif
1128 1147
1129 1148
1130 Operand ApiParameterOperand(int index) { 1149 Operand ApiParameterOperand(int index) {
1131 return Operand(esp, (index + (kPassHandlesDirectly ? 0 : 1)) * kPointerSize); 1150 return Operand(esp, (index + (kPassHandlesDirectly ? 0 : 1)) * kPointerSize);
1132 } 1151 }
1133 1152
1134 1153
1135 void MacroAssembler::PrepareCallApiFunction(int stack_space, int argc) { 1154 void MacroAssembler::PrepareCallApiFunction(int stack_space, int argc) {
1136 if (kPassHandlesDirectly) { 1155 if (kPassHandlesDirectly) {
1137 EnterApiExitFrame(stack_space, argc); 1156 EnterApiExitFrame(stack_space, argc);
1138 // When handles as passed directly we don't have to allocate extra 1157 // When handles as passed directly we don't have to allocate extra
1139 // space for and pass an out parameter. 1158 // space for and pass an out parameter.
1140 } else { 1159 } else {
1141 // We allocate two additional slots: return value and pointer to it. 1160 // We allocate two additional slots: return value and pointer to it.
1142 EnterApiExitFrame(stack_space, argc + 2); 1161 EnterApiExitFrame(stack_space, argc + 2);
1143 } 1162 }
1144 } 1163 }
1145 1164
1146 1165
1147 void MacroAssembler::CallApiFunctionAndReturn(ApiFunction* function, int argc) { 1166 MaybeObject* MacroAssembler::TryCallApiFunctionAndReturn(ApiFunction* function,
1167 int argc) {
1148 if (!kPassHandlesDirectly) { 1168 if (!kPassHandlesDirectly) {
1149 // The argument slots are filled as follows: 1169 // The argument slots are filled as follows:
1150 // 1170 //
1151 // n + 1: output cell 1171 // n + 1: output cell
1152 // n: arg n 1172 // n: arg n
1153 // ... 1173 // ...
1154 // 1: arg1 1174 // 1: arg1
1155 // 0: pointer to the output cell 1175 // 0: pointer to the output cell
1156 // 1176 //
1157 // Note that this is one more "argument" than the function expects 1177 // Note that this is one more "argument" than the function expects
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 1226
1207 // Check if the function scheduled an exception. 1227 // Check if the function scheduled an exception.
1208 ExternalReference scheduled_exception_address = 1228 ExternalReference scheduled_exception_address =
1209 ExternalReference::scheduled_exception_address(); 1229 ExternalReference::scheduled_exception_address();
1210 cmp(Operand::StaticVariable(scheduled_exception_address), 1230 cmp(Operand::StaticVariable(scheduled_exception_address),
1211 Immediate(Factory::the_hole_value())); 1231 Immediate(Factory::the_hole_value()));
1212 j(not_equal, &promote_scheduled_exception, not_taken); 1232 j(not_equal, &promote_scheduled_exception, not_taken);
1213 LeaveExitFrame(); 1233 LeaveExitFrame();
1214 ret(0); 1234 ret(0);
1215 bind(&promote_scheduled_exception); 1235 bind(&promote_scheduled_exception);
1216 TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1); 1236 MaybeObject* result =
1237 TryTailCallRuntime(Runtime::kPromoteScheduledException, 0, 1);
1238 if (result->IsFailure()) {
1239 return result;
1240 }
1217 bind(&empty_handle); 1241 bind(&empty_handle);
1218 // It was zero; the result is undefined. 1242 // It was zero; the result is undefined.
1219 mov(eax, Factory::undefined_value()); 1243 mov(eax, Factory::undefined_value());
1220 jmp(&prologue); 1244 jmp(&prologue);
1221 1245
1222 // HandleScope limit has changed. Delete allocated extensions. 1246 // HandleScope limit has changed. Delete allocated extensions.
1223 bind(&delete_allocated_handles); 1247 bind(&delete_allocated_handles);
1224 mov(Operand::StaticVariable(limit_address), edi); 1248 mov(Operand::StaticVariable(limit_address), edi);
1225 mov(edi, eax); 1249 mov(edi, eax);
1226 mov(eax, Immediate(ExternalReference::delete_handle_scope_extensions())); 1250 mov(eax, Immediate(ExternalReference::delete_handle_scope_extensions()));
1227 call(Operand(eax)); 1251 call(Operand(eax));
1228 mov(eax, edi); 1252 mov(eax, edi);
1229 jmp(&leave_exit_frame); 1253 jmp(&leave_exit_frame);
1254
1255 return result;
1230 } 1256 }
1231 1257
1232 1258
1233 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext) { 1259 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext) {
1234 // Set the entry point and jump to the C entry runtime stub. 1260 // Set the entry point and jump to the C entry runtime stub.
1235 mov(ebx, Immediate(ext)); 1261 mov(ebx, Immediate(ext));
1236 CEntryStub ces(1); 1262 CEntryStub ces(1);
1237 jmp(ces.GetCode(), RelocInfo::CODE_TARGET); 1263 jmp(ces.GetCode(), RelocInfo::CODE_TARGET);
1238 } 1264 }
1239 1265
1240 1266
1267 MaybeObject* MacroAssembler::TryJumpToExternalReference(
1268 const ExternalReference& ext) {
1269 // Set the entry point and jump to the C entry runtime stub.
1270 mov(ebx, Immediate(ext));
1271 CEntryStub ces(1);
1272 return TryTailCallStub(&ces);
1273 }
1274
1275
1241 void MacroAssembler::InvokePrologue(const ParameterCount& expected, 1276 void MacroAssembler::InvokePrologue(const ParameterCount& expected,
1242 const ParameterCount& actual, 1277 const ParameterCount& actual,
1243 Handle<Code> code_constant, 1278 Handle<Code> code_constant,
1244 const Operand& code_operand, 1279 const Operand& code_operand,
1245 Label* done, 1280 Label* done,
1246 InvokeFlag flag) { 1281 InvokeFlag flag) {
1247 bool definitely_matches = false; 1282 bool definitely_matches = false;
1248 Label invoke; 1283 Label invoke;
1249 if (expected.is_immediate()) { 1284 if (expected.is_immediate()) {
1250 ASSERT(actual.is_immediate()); 1285 ASSERT(actual.is_immediate());
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 1799
1765 // Check that the code was patched as expected. 1800 // Check that the code was patched as expected.
1766 ASSERT(masm_.pc_ == address_ + size_); 1801 ASSERT(masm_.pc_ == address_ + size_);
1767 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 1802 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
1768 } 1803 }
1769 1804
1770 1805
1771 } } // namespace v8::internal 1806 } } // namespace v8::internal
1772 1807
1773 #endif // V8_TARGET_ARCH_IA32 1808 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698