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

Side by Side Diff: src/arm/deoptimizer-arm.cc

Issue 9265004: Support inlining at call-sites with mismatched number of arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: finished implementation, extended tests, ported to x64&arm Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2012 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
11 // with the distribution. 11 // with the distribution.
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 int bailout_id = LookupBailoutId(data, ast_id); 204 int bailout_id = LookupBailoutId(data, ast_id);
205 unsigned translation_index = data->TranslationIndex(bailout_id)->value(); 205 unsigned translation_index = data->TranslationIndex(bailout_id)->value();
206 ByteArray* translations = data->TranslationByteArray(); 206 ByteArray* translations = data->TranslationByteArray();
207 207
208 TranslationIterator iterator(translations, translation_index); 208 TranslationIterator iterator(translations, translation_index);
209 Translation::Opcode opcode = 209 Translation::Opcode opcode =
210 static_cast<Translation::Opcode>(iterator.Next()); 210 static_cast<Translation::Opcode>(iterator.Next());
211 ASSERT(Translation::BEGIN == opcode); 211 ASSERT(Translation::BEGIN == opcode);
212 USE(opcode); 212 USE(opcode);
213 int count = iterator.Next(); 213 int count = iterator.Next();
214 iterator.Skip(1); // Drop JS frame count.
214 ASSERT(count == 1); 215 ASSERT(count == 1);
215 USE(count); 216 USE(count);
216 217
217 opcode = static_cast<Translation::Opcode>(iterator.Next()); 218 opcode = static_cast<Translation::Opcode>(iterator.Next());
218 USE(opcode); 219 USE(opcode);
219 ASSERT(Translation::FRAME == opcode); 220 ASSERT(Translation::JS_FRAME == opcode);
220 unsigned node_id = iterator.Next(); 221 unsigned node_id = iterator.Next();
221 USE(node_id); 222 USE(node_id);
222 ASSERT(node_id == ast_id); 223 ASSERT(node_id == ast_id);
223 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator.Next())); 224 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator.Next()));
224 USE(function); 225 USE(function);
225 ASSERT(function == function_); 226 ASSERT(function == function_);
226 unsigned height = iterator.Next(); 227 unsigned height = iterator.Next();
227 unsigned height_in_bytes = height * kPointerSize; 228 unsigned height_in_bytes = height * kPointerSize;
228 USE(height_in_bytes); 229 USE(height_in_bytes);
229 230
(...skipping 18 matching lines...) Expand all
248 } 249 }
249 250
250 // There's only one output frame in the OSR case. 251 // There's only one output frame in the OSR case.
251 output_count_ = 1; 252 output_count_ = 1;
252 output_ = new FrameDescription*[1]; 253 output_ = new FrameDescription*[1];
253 output_[0] = new(output_frame_size) FrameDescription( 254 output_[0] = new(output_frame_size) FrameDescription(
254 output_frame_size, function_); 255 output_frame_size, function_);
255 #ifdef DEBUG 256 #ifdef DEBUG
256 output_[0]->SetKind(Code::OPTIMIZED_FUNCTION); 257 output_[0]->SetKind(Code::OPTIMIZED_FUNCTION);
257 #endif 258 #endif
259 output_[0]->SetType(StackFrame::JAVA_SCRIPT);
258 260
259 // Clear the incoming parameters in the optimized frame to avoid 261 // Clear the incoming parameters in the optimized frame to avoid
260 // confusing the garbage collector. 262 // confusing the garbage collector.
261 unsigned output_offset = output_frame_size - kPointerSize; 263 unsigned output_offset = output_frame_size - kPointerSize;
262 int parameter_count = function_->shared()->formal_parameter_count() + 1; 264 int parameter_count = function_->shared()->formal_parameter_count() + 1;
263 for (int i = 0; i < parameter_count; ++i) { 265 for (int i = 0; i < parameter_count; ++i) {
264 output_[0]->SetFrameSlot(output_offset, 0); 266 output_[0]->SetFrameSlot(output_offset, 0);
265 output_offset -= kPointerSize; 267 output_offset -= kPointerSize;
266 } 268 }
267 269
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 if (FLAG_trace_osr) { 337 if (FLAG_trace_osr) {
336 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", 338 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ",
337 ok ? "finished" : "aborted", 339 ok ? "finished" : "aborted",
338 reinterpret_cast<intptr_t>(function)); 340 reinterpret_cast<intptr_t>(function));
339 function->PrintName(); 341 function->PrintName();
340 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc()); 342 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc());
341 } 343 }
342 } 344 }
343 345
344 346
347 void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator,
348 int frame_index) {
349 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
350 unsigned height = iterator->Next();
351 unsigned height_in_bytes = height * kPointerSize;
352 if (FLAG_trace_deopt) {
353 PrintF(" translating arguments adaptor => height=%d\n", height_in_bytes);
354 }
355
356 unsigned fixed_frame_size = 5 * kPointerSize;
357 unsigned input_frame_size = input_->GetFrameSize();
358 unsigned output_frame_size = height_in_bytes + fixed_frame_size;
359
360 // Allocate and store the output frame description.
361 FrameDescription* output_frame =
362 new(output_frame_size) FrameDescription(output_frame_size, function);
363 #ifdef DEBUG
364 output_frame->SetKind(Code::BUILTIN);
365 #endif
366 output_frame->SetType(StackFrame::ARGUMENTS_ADAPTOR);
367
368 // Arguments adaptor can not be topmost or bottommost.
369 ASSERT(frame_index > 0 && frame_index < output_count_ - 1);
370 ASSERT(output_[frame_index] == NULL);
371 output_[frame_index] = output_frame;
372
373 // The top address for the bottommost output frame can be computed from
Kevin Millikin (Chromium) 2012/01/24 00:08:54 The first half of this comment can be dropped. Su
Vyacheslav Egorov (Chromium) 2012/01/24 08:49:20 Done.
374 // the input frame pointer and the output frame's height. For all
375 // subsequent output frames, it can be computed from the previous one's
376 // top address and the current frame's size.
377 uint32_t top_address;
378 top_address = output_[frame_index - 1]->GetTop() - output_frame_size;
379 output_frame->SetTop(top_address);
380
381 // Compute the incoming parameter translation.
382 int parameter_count = height;
383 unsigned output_offset = output_frame_size;
384 unsigned input_offset = input_frame_size;
385 for (int i = 0; i < parameter_count; ++i) {
386 output_offset -= kPointerSize;
387 DoTranslateCommand(iterator, frame_index, output_offset);
388 }
389 input_offset -= (parameter_count * kPointerSize);
390
391 // Compute caller's PC
Kevin Millikin (Chromium) 2012/01/24 00:08:54 Read caller's PC from the previous frame.
Vyacheslav Egorov (Chromium) 2012/01/24 08:49:20 Done.
392 output_offset -= kPointerSize;
393 input_offset -= kPointerSize;
394 intptr_t callers_pc = output_[frame_index - 1]->GetPc();
395 output_frame->SetFrameSlot(output_offset, callers_pc);
396 if (FLAG_trace_deopt) {
397 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's pc\n",
398 top_address + output_offset, output_offset, callers_pc);
399 }
400
401 // Compute caller's FP
Kevin Millikin (Chromium) 2012/01/24 00:08:54 Read caller's FP from the previous frame, and set
Vyacheslav Egorov (Chromium) 2012/01/24 08:49:20 Done.
402 output_offset -= kPointerSize;
403 input_offset -= kPointerSize;
404 intptr_t value = output_[frame_index - 1]->GetFp();
405 output_frame->SetFrameSlot(output_offset, value);
406 intptr_t fp_value = top_address + output_offset;
407 output_frame->SetFp(fp_value);
408 if (FLAG_trace_deopt) {
409 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n",
410 fp_value, output_offset, value);
411 }
412
413 // For the bottommost output frame the context can be gotten from the input
Kevin Millikin (Chromium) 2012/01/24 00:08:54 Comment is just wrong: "A marker value is used in
Vyacheslav Egorov (Chromium) 2012/01/24 08:49:20 Done.
414 // frame. For all subsequent output frames it can be gotten from the function
415 // so long as we don't inline functions that need local contexts.
416 output_offset -= kPointerSize;
417 input_offset -= kPointerSize;
418 intptr_t context = reinterpret_cast<intptr_t>(
419 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
420 output_frame->SetFrameSlot(output_offset, context);
421 if (FLAG_trace_deopt) {
422 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context (adaptor sentinel)\n",
423 top_address + output_offset, output_offset, context);
424 }
425
426 // The function was mentioned explicitly in the ARGUMENTS_ADAPTOR_FRAME.
427 output_offset -= kPointerSize;
428 input_offset -= kPointerSize;
429 value = reinterpret_cast<intptr_t>(function);
430 output_frame->SetFrameSlot(output_offset, value);
431 if (FLAG_trace_deopt) {
432 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function\n",
433 top_address + output_offset, output_offset, value);
434 }
435
436 // Number of incomming arguments.
Kevin Millikin (Chromium) 2012/01/24 00:08:54 incomming => incoming
Vyacheslav Egorov (Chromium) 2012/01/24 08:49:20 Done.
437 output_offset -= kPointerSize;
438 input_offset -= kPointerSize;
439 value = reinterpret_cast<uint32_t>(Smi::FromInt(height - 1));
440 output_frame->SetFrameSlot(output_offset, value);
441 if (FLAG_trace_deopt) {
442 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; argc (%d)\n",
443 top_address + output_offset, output_offset, value, height - 1);
444 }
445
446 ASSERT(0 == output_offset);
447
448 Builtins* builtins = isolate_->builtins();
449 Code* adaptor_trampoline =
450 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline);
451 uint32_t pc = reinterpret_cast<uint32_t>(
452 adaptor_trampoline->instruction_start() +
453 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value());
454 output_frame->SetPc(pc);
455 }
456
457
345 // This code is very similar to ia32 code, but relies on register names (fp, sp) 458 // This code is very similar to ia32 code, but relies on register names (fp, sp)
346 // and how the frame is laid out. 459 // and how the frame is laid out.
347 void Deoptimizer::DoComputeFrame(TranslationIterator* iterator, 460 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator,
348 int frame_index) { 461 int frame_index) {
349 // Read the ast node id, function, and frame height for this output frame. 462 // Read the ast node id, function, and frame height for this output frame.
350 Translation::Opcode opcode =
351 static_cast<Translation::Opcode>(iterator->Next());
352 USE(opcode);
353 ASSERT(Translation::FRAME == opcode);
354 int node_id = iterator->Next(); 463 int node_id = iterator->Next();
355 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); 464 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
356 unsigned height = iterator->Next(); 465 unsigned height = iterator->Next();
357 unsigned height_in_bytes = height * kPointerSize; 466 unsigned height_in_bytes = height * kPointerSize;
358 if (FLAG_trace_deopt) { 467 if (FLAG_trace_deopt) {
359 PrintF(" translating "); 468 PrintF(" translating ");
360 function->PrintName(); 469 function->PrintName();
361 PrintF(" => node=%d, height=%d\n", node_id, height_in_bytes); 470 PrintF(" => node=%d, height=%d\n", node_id, height_in_bytes);
362 } 471 }
363 472
364 // The 'fixed' part of the frame consists of the incoming parameters and 473 // The 'fixed' part of the frame consists of the incoming parameters and
365 // the part described by JavaScriptFrameConstants. 474 // the part described by JavaScriptFrameConstants.
366 unsigned fixed_frame_size = ComputeFixedSize(function); 475 unsigned fixed_frame_size = ComputeFixedSize(function);
367 unsigned input_frame_size = input_->GetFrameSize(); 476 unsigned input_frame_size = input_->GetFrameSize();
368 unsigned output_frame_size = height_in_bytes + fixed_frame_size; 477 unsigned output_frame_size = height_in_bytes + fixed_frame_size;
369 478
370 // Allocate and store the output frame description. 479 // Allocate and store the output frame description.
371 FrameDescription* output_frame = 480 FrameDescription* output_frame =
372 new(output_frame_size) FrameDescription(output_frame_size, function); 481 new(output_frame_size) FrameDescription(output_frame_size, function);
373 #ifdef DEBUG 482 #ifdef DEBUG
374 output_frame->SetKind(Code::FUNCTION); 483 output_frame->SetKind(Code::FUNCTION);
375 #endif 484 #endif
485 output_frame->SetType(StackFrame::JAVA_SCRIPT);
376 486
377 bool is_bottommost = (0 == frame_index); 487 bool is_bottommost = (0 == frame_index);
378 bool is_topmost = (output_count_ - 1 == frame_index); 488 bool is_topmost = (output_count_ - 1 == frame_index);
379 ASSERT(frame_index >= 0 && frame_index < output_count_); 489 ASSERT(frame_index >= 0 && frame_index < output_count_);
380 ASSERT(output_[frame_index] == NULL); 490 ASSERT(output_[frame_index] == NULL);
381 output_[frame_index] = output_frame; 491 output_[frame_index] = output_frame;
382 492
383 // The top address for the bottommost output frame can be computed from 493 // The top address for the bottommost output frame can be computed from
384 // the input frame pointer and the output frame's height. For all 494 // the input frame pointer and the output frame's height. For all
385 // subsequent output frames, it can be computed from the previous one's 495 // subsequent output frames, it can be computed from the previous one's
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 __ push(ip); 860 __ push(ip);
751 __ b(&done); 861 __ b(&done);
752 ASSERT(masm()->pc_offset() - start == table_entry_size_); 862 ASSERT(masm()->pc_offset() - start == table_entry_size_);
753 } 863 }
754 __ bind(&done); 864 __ bind(&done);
755 } 865 }
756 866
757 #undef __ 867 #undef __
758 868
759 } } // namespace v8::internal 869 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/arm/frames-arm.h » ('j') | src/deoptimizer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698