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

Side by Side Diff: src/builtins/arm64/builtins-arm64.cc

Issue 2307903002: [Interpreter] Collect allocation site feedback in call bytecode handler. (Closed)
Patch Set: ia32, arm and arm64 ports. Created 4 years, 3 months 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 #if V8_TARGET_ARCH_ARM64 5 #if V8_TARGET_ARCH_ARM64
6 6
7 #include "src/arm64/frames-arm64.h" 7 #include "src/arm64/frames-arm64.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 // Push function as argument and compile for baseline. 1164 // Push function as argument and compile for baseline.
1165 __ push(x1); 1165 __ push(x1);
1166 __ CallRuntime(Runtime::kCompileBaseline); 1166 __ CallRuntime(Runtime::kCompileBaseline);
1167 1167
1168 // Restore return value. 1168 // Restore return value.
1169 __ pop(x0); 1169 __ pop(x0);
1170 } 1170 }
1171 __ Ret(); 1171 __ Ret();
1172 } 1172 }
1173 1173
1174 static void Generate_InterpreterPushArgs(MacroAssembler* masm,
1175 Register num_args, Register first_arg,
1176 bool receiver_available) {
1177 Register scratch = x5, last_addr = x6, stack_addr = x7;
rmcilroy 2016/09/06 10:59:35 please pass these as arguments
mythria 2016/09/07 08:59:44 Done.
1178
1179 // TODO(mythria): Add a stack check before pushing arguments.
1180 // Find the size of arguments.
1181 __ add(scratch, num_args, Operand(1)); // Add one for receiver.
1182 __ lsl(scratch, scratch, kPointerSizeLog2);
1183
1184 // Set stack pointer and where to stop.
1185 __ Mov(stack_addr, jssp);
1186 __ Claim(scratch, 1);
1187
1188 // Find the last destination address.
1189 __ sub(last_addr, stack_addr, scratch);
1190
1191 if (!receiver_available) {
1192 // Push a slot for the receiver.
1193 __ Str(xzr, MemOperand(stack_addr, -kPointerSize, PreIndex));
1194 }
rmcilroy 2016/09/06 10:59:35 nit - could you just do this in InterpreterPushArg
mythria 2016/09/07 08:59:44 Done.
1195
1196 // Push the arguments.
1197 Label loop_header, loop_check;
1198 __ B(&loop_check);
1199 __ Bind(&loop_header);
1200 // TODO(rmcilroy): Push two at a time once we ensure we keep stack aligned.
1201 __ Ldr(scratch, MemOperand(first_arg, -kPointerSize, PostIndex));
1202 __ Str(scratch, MemOperand(stack_addr, -kPointerSize, PreIndex));
1203 __ Bind(&loop_check);
1204 __ Cmp(stack_addr, last_addr);
1205 __ B(gt, &loop_header);
1206 }
1207
1174 // static 1208 // static
1175 void Builtins::Generate_InterpreterPushArgsAndCallImpl( 1209 void Builtins::Generate_InterpreterPushArgsAndCallImpl(
1176 MacroAssembler* masm, TailCallMode tail_call_mode, 1210 MacroAssembler* masm, TailCallMode tail_call_mode,
1177 CallableType function_type) { 1211 CallableType function_type) {
1178 // ----------- S t a t e ------------- 1212 // ----------- S t a t e -------------
1179 // -- x0 : the number of arguments (not including the receiver) 1213 // -- x0 : the number of arguments (not including the receiver)
1180 // -- x2 : the address of the first argument to be pushed. Subsequent 1214 // -- x2 : the address of the first argument to be pushed. Subsequent
1181 // arguments should be consecutive above this, in the same order as 1215 // arguments should be consecutive above this, in the same order as
1182 // they are to be pushed onto the stack. 1216 // they are to be pushed onto the stack.
1183 // -- x1 : the target to call (can be any Object). 1217 // -- x1 : the target to call (can be any Object).
1184 // ----------------------------------- 1218 // -----------------------------------
1185 1219
1186 // Find the address of the last argument.
1187 __ add(x3, x0, Operand(1)); // Add one for receiver.
1188 __ lsl(x3, x3, kPointerSizeLog2);
1189 __ sub(x4, x2, x3);
1190
1191 // TODO(mythria): Add a stack check before pushing arguments.
1192 // Push the arguments. 1220 // Push the arguments.
1193 Label loop_header, loop_check; 1221 Generate_InterpreterPushArgs(masm, x0, x2, true);
1194 __ Mov(x5, jssp);
1195 __ Claim(x3, 1);
1196 __ B(&loop_check);
1197 __ Bind(&loop_header);
1198 // TODO(rmcilroy): Push two at a time once we ensure we keep stack aligned.
1199 __ Ldr(x3, MemOperand(x2, -kPointerSize, PostIndex));
1200 __ Str(x3, MemOperand(x5, -kPointerSize, PreIndex));
1201 __ Bind(&loop_check);
1202 __ Cmp(x2, x4);
1203 __ B(gt, &loop_header);
1204 1222
1205 // Call the target. 1223 // Call the target.
1206 if (function_type == CallableType::kJSFunction) { 1224 if (function_type == CallableType::kJSFunction) {
1207 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, 1225 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny,
1208 tail_call_mode), 1226 tail_call_mode),
1209 RelocInfo::CODE_TARGET); 1227 RelocInfo::CODE_TARGET);
1210 } else { 1228 } else {
1211 DCHECK_EQ(function_type, CallableType::kAny); 1229 DCHECK_EQ(function_type, CallableType::kAny);
1212 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, 1230 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny,
1213 tail_call_mode), 1231 tail_call_mode),
1214 RelocInfo::CODE_TARGET); 1232 RelocInfo::CODE_TARGET);
1215 } 1233 }
1216 } 1234 }
1217 1235
1218 // static 1236 // static
1219 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( 1237 void Builtins::Generate_InterpreterPushArgsAndConstructImpl(
1220 MacroAssembler* masm, CallableType construct_type) { 1238 MacroAssembler* masm, CallableType construct_type) {
1221 // ----------- S t a t e ------------- 1239 // ----------- S t a t e -------------
1222 // -- x0 : argument count (not including receiver) 1240 // -- x0 : argument count (not including receiver)
1223 // -- x3 : new target 1241 // -- x3 : new target
1224 // -- x1 : constructor to call 1242 // -- x1 : constructor to call
1225 // -- x2 : allocation site feedback if available, undefined otherwise 1243 // -- x2 : allocation site feedback if available, undefined otherwise
1226 // -- x4 : address of the first argument 1244 // -- x4 : address of the first argument
1227 // ----------------------------------- 1245 // -----------------------------------
1228 1246
1229 // Find the address of the last argument.
1230 __ add(x5, x0, Operand(1)); // Add one for receiver (to be constructed).
1231 __ lsl(x5, x5, kPointerSizeLog2);
1232
1233 // Set stack pointer and where to stop.
1234 __ Mov(x6, jssp);
1235 __ Claim(x5, 1);
1236 __ sub(x7, x6, x5);
1237
1238 // Push a slot for the receiver.
1239 __ Str(xzr, MemOperand(x6, -kPointerSize, PreIndex));
1240
1241 Label loop_header, loop_check;
1242 // TODO(mythria): Add a stack check before pushing arguments.
1243 // Push the arguments. 1247 // Push the arguments.
1244 __ B(&loop_check); 1248 Generate_InterpreterPushArgs(masm, x0, x4, false);
1245 __ Bind(&loop_header);
1246 // TODO(rmcilroy): Push two at a time once we ensure we keep stack aligned.
1247 __ Ldr(x5, MemOperand(x4, -kPointerSize, PostIndex));
1248 __ Str(x5, MemOperand(x6, -kPointerSize, PreIndex));
1249 __ Bind(&loop_check);
1250 __ Cmp(x6, x7);
1251 __ B(gt, &loop_header);
1252 1249
1253 __ AssertUndefinedOrAllocationSite(x2, x6); 1250 __ AssertUndefinedOrAllocationSite(x2, x6);
1254 if (construct_type == CallableType::kJSFunction) { 1251 if (construct_type == CallableType::kJSFunction) {
1255 __ AssertFunction(x1); 1252 __ AssertFunction(x1);
1256 1253
1257 // Tail call to the function-specific construct stub (still in the caller 1254 // Tail call to the function-specific construct stub (still in the caller
1258 // context at this point). 1255 // context at this point).
1259 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); 1256 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset));
1260 __ Ldr(x4, FieldMemOperand(x4, SharedFunctionInfo::kConstructStubOffset)); 1257 __ Ldr(x4, FieldMemOperand(x4, SharedFunctionInfo::kConstructStubOffset));
1261 __ Add(x4, x4, Code::kHeaderSize - kHeapObjectTag); 1258 __ Add(x4, x4, Code::kHeaderSize - kHeapObjectTag);
1262 __ Br(x4); 1259 __ Br(x4);
1263 } else { 1260 } else {
1264 DCHECK_EQ(construct_type, CallableType::kAny); 1261 DCHECK_EQ(construct_type, CallableType::kAny);
1265 // Call the constructor with x0, x1, and x3 unmodified. 1262 // Call the constructor with x0, x1, and x3 unmodified.
1266 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 1263 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
1267 } 1264 }
1268 } 1265 }
1269 1266
1267 // static
1268 void Builtins::Generate_InterpreterPushArgsAndConstructArray(
1269 MacroAssembler* masm) {
1270 // ----------- S t a t e -------------
1271 // -- x0 : argument count (not including receiver)
1272 // -- x1 : target to call verified to be Array function
1273 // -- x2 : allocation site feedback if available, undefined otherwise.
1274 // -- x3 : address of the first argument
1275 // -----------------------------------
1276
1277 // Push the arguments.
1278 Generate_InterpreterPushArgs(masm, x0, x3, true);
1279
1280 // Array constructor expects constructor in x3. It is same as call target.
1281 __ mov(x3, x1);
1282
1283 ArrayConstructorStub stub(masm->isolate());
1284 __ TailCallStub(&stub);
1285 }
1286
1270 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { 1287 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) {
1271 // Set the return address to the correct point in the interpreter entry 1288 // Set the return address to the correct point in the interpreter entry
1272 // trampoline. 1289 // trampoline.
1273 Smi* interpreter_entry_return_pc_offset( 1290 Smi* interpreter_entry_return_pc_offset(
1274 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); 1291 masm->isolate()->heap()->interpreter_entry_return_pc_offset());
1275 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); 1292 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0));
1276 __ LoadObject(x1, masm->isolate()->builtins()->InterpreterEntryTrampoline()); 1293 __ LoadObject(x1, masm->isolate()->builtins()->InterpreterEntryTrampoline());
1277 __ Add(lr, x1, Operand(interpreter_entry_return_pc_offset->value() + 1294 __ Add(lr, x1, Operand(interpreter_entry_return_pc_offset->value() +
1278 Code::kHeaderSize - kHeapObjectTag)); 1295 Code::kHeaderSize - kHeapObjectTag));
1279 1296
(...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after
3064 __ Unreachable(); 3081 __ Unreachable();
3065 } 3082 }
3066 } 3083 }
3067 3084
3068 #undef __ 3085 #undef __
3069 3086
3070 } // namespace internal 3087 } // namespace internal
3071 } // namespace v8 3088 } // namespace v8
3072 3089
3073 #endif // V8_TARGET_ARCH_ARM 3090 #endif // V8_TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698