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

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

Issue 1455293004: Simplify MacroAssembler::InvokePrologue a bit. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix MIPS64 compilation. Created 5 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
« no previous file with comments | « src/mips64/macro-assembler-mips64.h ('k') | src/ppc/macro-assembler-ppc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <limits.h> // For LONG_MIN, LONG_MAX. 5 #include <limits.h> // For LONG_MIN, LONG_MAX.
6 6
7 #if V8_TARGET_ARCH_MIPS64 7 #if V8_TARGET_ARCH_MIPS64
8 8
9 #include "src/base/division-by-constant.h" 9 #include "src/base/division-by-constant.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 4138 matching lines...) Expand 10 before | Expand all | Expand 10 after
4149 } 4149 }
4150 } 4150 }
4151 } 4151 }
4152 4152
4153 4153
4154 // ----------------------------------------------------------------------------- 4154 // -----------------------------------------------------------------------------
4155 // JavaScript invokes. 4155 // JavaScript invokes.
4156 4156
4157 void MacroAssembler::InvokePrologue(const ParameterCount& expected, 4157 void MacroAssembler::InvokePrologue(const ParameterCount& expected,
4158 const ParameterCount& actual, 4158 const ParameterCount& actual,
4159 Handle<Code> code_constant,
4160 Register code_reg,
4161 Label* done, 4159 Label* done,
4162 bool* definitely_mismatches, 4160 bool* definitely_mismatches,
4163 InvokeFlag flag, 4161 InvokeFlag flag,
4164 const CallWrapper& call_wrapper) { 4162 const CallWrapper& call_wrapper) {
4165 bool definitely_matches = false; 4163 bool definitely_matches = false;
4166 *definitely_mismatches = false; 4164 *definitely_mismatches = false;
4167 Label regular_invoke; 4165 Label regular_invoke;
4168 4166
4169 // Check whether the expected and actual arguments count match. If not, 4167 // Check whether the expected and actual arguments count match. If not,
4170 // setup registers according to contract with ArgumentsAdaptorTrampoline: 4168 // setup registers according to contract with ArgumentsAdaptorTrampoline:
4171 // a0: actual arguments count 4169 // a0: actual arguments count
4172 // a1: function (passed through to callee) 4170 // a1: function (passed through to callee)
4173 // a2: expected arguments count 4171 // a2: expected arguments count
4174 4172
4175 // The code below is made a lot easier because the calling code already sets 4173 // The code below is made a lot easier because the calling code already sets
4176 // up actual and expected registers according to the contract if values are 4174 // up actual and expected registers according to the contract if values are
4177 // passed in registers. 4175 // passed in registers.
4178 DCHECK(actual.is_immediate() || actual.reg().is(a0)); 4176 DCHECK(actual.is_immediate() || actual.reg().is(a0));
4179 DCHECK(expected.is_immediate() || expected.reg().is(a2)); 4177 DCHECK(expected.is_immediate() || expected.reg().is(a2));
4180 DCHECK((!code_constant.is_null() && code_reg.is(no_reg)) || code_reg.is(a3));
4181 4178
4182 if (expected.is_immediate()) { 4179 if (expected.is_immediate()) {
4183 DCHECK(actual.is_immediate()); 4180 DCHECK(actual.is_immediate());
4184 li(a0, Operand(actual.immediate())); 4181 li(a0, Operand(actual.immediate()));
4185 if (expected.immediate() == actual.immediate()) { 4182 if (expected.immediate() == actual.immediate()) {
4186 definitely_matches = true; 4183 definitely_matches = true;
4187 } else { 4184 } else {
4188 const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel; 4185 const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel;
4189 if (expected.immediate() == sentinel) { 4186 if (expected.immediate() == sentinel) {
4190 // Don't worry about adapting arguments for builtins that 4187 // Don't worry about adapting arguments for builtins that
4191 // don't want that done. Skip adaption code by making it look 4188 // don't want that done. Skip adaption code by making it look
4192 // like we have a match between expected and actual number of 4189 // like we have a match between expected and actual number of
4193 // arguments. 4190 // arguments.
4194 definitely_matches = true; 4191 definitely_matches = true;
4195 } else { 4192 } else {
4196 *definitely_mismatches = true; 4193 *definitely_mismatches = true;
4197 li(a2, Operand(expected.immediate())); 4194 li(a2, Operand(expected.immediate()));
4198 } 4195 }
4199 } 4196 }
4200 } else if (actual.is_immediate()) { 4197 } else if (actual.is_immediate()) {
4201 li(a0, Operand(actual.immediate())); 4198 li(a0, Operand(actual.immediate()));
4202 Branch(&regular_invoke, eq, expected.reg(), Operand(a0)); 4199 Branch(&regular_invoke, eq, expected.reg(), Operand(a0));
4203 } else { 4200 } else {
4204 Branch(&regular_invoke, eq, expected.reg(), Operand(actual.reg())); 4201 Branch(&regular_invoke, eq, expected.reg(), Operand(actual.reg()));
4205 } 4202 }
4206 4203
4207 if (!definitely_matches) { 4204 if (!definitely_matches) {
4208 if (!code_constant.is_null()) {
4209 li(a3, Operand(code_constant));
4210 daddiu(a3, a3, Code::kHeaderSize - kHeapObjectTag);
4211 }
4212
4213 Handle<Code> adaptor = 4205 Handle<Code> adaptor =
4214 isolate()->builtins()->ArgumentsAdaptorTrampoline(); 4206 isolate()->builtins()->ArgumentsAdaptorTrampoline();
4215 if (flag == CALL_FUNCTION) { 4207 if (flag == CALL_FUNCTION) {
4216 call_wrapper.BeforeCall(CallSize(adaptor)); 4208 call_wrapper.BeforeCall(CallSize(adaptor));
4217 Call(adaptor); 4209 Call(adaptor);
4218 call_wrapper.AfterCall(); 4210 call_wrapper.AfterCall();
4219 if (!*definitely_mismatches) { 4211 if (!*definitely_mismatches) {
4220 Branch(done); 4212 Branch(done);
4221 } 4213 }
4222 } else { 4214 } else {
4223 Jump(adaptor, RelocInfo::CODE_TARGET); 4215 Jump(adaptor, RelocInfo::CODE_TARGET);
4224 } 4216 }
4225 bind(&regular_invoke); 4217 bind(&regular_invoke);
4226 } 4218 }
4227 } 4219 }
4228 4220
4229 4221
4230 void MacroAssembler::InvokeCode(Register code, 4222 void MacroAssembler::InvokeCode(Register code,
4231 const ParameterCount& expected, 4223 const ParameterCount& expected,
4232 const ParameterCount& actual, 4224 const ParameterCount& actual,
4233 InvokeFlag flag, 4225 InvokeFlag flag,
4234 const CallWrapper& call_wrapper) { 4226 const CallWrapper& call_wrapper) {
4235 // You can't call a function without a valid frame. 4227 // You can't call a function without a valid frame.
4236 DCHECK(flag == JUMP_FUNCTION || has_frame()); 4228 DCHECK(flag == JUMP_FUNCTION || has_frame());
4237 4229
4238 Label done; 4230 Label done;
4239 4231
4240 bool definitely_mismatches = false; 4232 bool definitely_mismatches = false;
4241 InvokePrologue(expected, actual, Handle<Code>::null(), code, 4233 InvokePrologue(expected, actual, &done, &definitely_mismatches, flag,
4242 &done, &definitely_mismatches, flag,
4243 call_wrapper); 4234 call_wrapper);
4244 if (!definitely_mismatches) { 4235 if (!definitely_mismatches) {
4245 if (flag == CALL_FUNCTION) { 4236 if (flag == CALL_FUNCTION) {
4246 call_wrapper.BeforeCall(CallSize(code)); 4237 call_wrapper.BeforeCall(CallSize(code));
4247 Call(code); 4238 Call(code);
4248 call_wrapper.AfterCall(); 4239 call_wrapper.AfterCall();
4249 } else { 4240 } else {
4250 DCHECK(flag == JUMP_FUNCTION); 4241 DCHECK(flag == JUMP_FUNCTION);
4251 Jump(code); 4242 Jump(code);
4252 } 4243 }
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after
6237 if (mag.shift > 0) sra(result, result, mag.shift); 6228 if (mag.shift > 0) sra(result, result, mag.shift);
6238 srl(at, dividend, 31); 6229 srl(at, dividend, 31);
6239 Addu(result, result, Operand(at)); 6230 Addu(result, result, Operand(at));
6240 } 6231 }
6241 6232
6242 6233
6243 } // namespace internal 6234 } // namespace internal
6244 } // namespace v8 6235 } // namespace v8
6245 6236
6246 #endif // V8_TARGET_ARCH_MIPS64 6237 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips64/macro-assembler-mips64.h ('k') | src/ppc/macro-assembler-ppc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698