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

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

Issue 9271068: MIPS: Support inlining at call-sites with mismatched number of arguments. (Closed)
Patch Set: 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
« no previous file with comments | « src/mips/builtins-mips.cc ('k') | src/mips/frames-mips.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 int bailout_id = LookupBailoutId(data, ast_id); 211 int bailout_id = LookupBailoutId(data, ast_id);
212 unsigned translation_index = data->TranslationIndex(bailout_id)->value(); 212 unsigned translation_index = data->TranslationIndex(bailout_id)->value();
213 ByteArray* translations = data->TranslationByteArray(); 213 ByteArray* translations = data->TranslationByteArray();
214 214
215 TranslationIterator iterator(translations, translation_index); 215 TranslationIterator iterator(translations, translation_index);
216 Translation::Opcode opcode = 216 Translation::Opcode opcode =
217 static_cast<Translation::Opcode>(iterator.Next()); 217 static_cast<Translation::Opcode>(iterator.Next());
218 ASSERT(Translation::BEGIN == opcode); 218 ASSERT(Translation::BEGIN == opcode);
219 USE(opcode); 219 USE(opcode);
220 int count = iterator.Next(); 220 int count = iterator.Next();
221 iterator.Skip(1); // Drop JS frame count.
221 ASSERT(count == 1); 222 ASSERT(count == 1);
222 USE(count); 223 USE(count);
223 224
224 opcode = static_cast<Translation::Opcode>(iterator.Next()); 225 opcode = static_cast<Translation::Opcode>(iterator.Next());
225 USE(opcode); 226 USE(opcode);
226 ASSERT(Translation::FRAME == opcode); 227 ASSERT(Translation::JS_FRAME == opcode);
227 unsigned node_id = iterator.Next(); 228 unsigned node_id = iterator.Next();
228 USE(node_id); 229 USE(node_id);
229 ASSERT(node_id == ast_id); 230 ASSERT(node_id == ast_id);
230 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator.Next())); 231 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator.Next()));
231 USE(function); 232 USE(function);
232 ASSERT(function == function_); 233 ASSERT(function == function_);
233 unsigned height = iterator.Next(); 234 unsigned height = iterator.Next();
234 unsigned height_in_bytes = height * kPointerSize; 235 unsigned height_in_bytes = height * kPointerSize;
235 USE(height_in_bytes); 236 USE(height_in_bytes);
236 237
(...skipping 15 matching lines...) Expand all
252 ast_id, 253 ast_id,
253 input_frame_size, 254 input_frame_size,
254 output_frame_size); 255 output_frame_size);
255 } 256 }
256 257
257 // There's only one output frame in the OSR case. 258 // There's only one output frame in the OSR case.
258 output_count_ = 1; 259 output_count_ = 1;
259 output_ = new FrameDescription*[1]; 260 output_ = new FrameDescription*[1];
260 output_[0] = new(output_frame_size) FrameDescription( 261 output_[0] = new(output_frame_size) FrameDescription(
261 output_frame_size, function_); 262 output_frame_size, function_);
262 #ifdef DEBUG 263 output_[0]->SetFrameType(StackFrame::JAVA_SCRIPT);
263 output_[0]->SetKind(Code::OPTIMIZED_FUNCTION);
264 #endif
265 264
266 // Clear the incoming parameters in the optimized frame to avoid 265 // Clear the incoming parameters in the optimized frame to avoid
267 // confusing the garbage collector. 266 // confusing the garbage collector.
268 unsigned output_offset = output_frame_size - kPointerSize; 267 unsigned output_offset = output_frame_size - kPointerSize;
269 int parameter_count = function_->shared()->formal_parameter_count() + 1; 268 int parameter_count = function_->shared()->formal_parameter_count() + 1;
270 for (int i = 0; i < parameter_count; ++i) { 269 for (int i = 0; i < parameter_count; ++i) {
271 output_[0]->SetFrameSlot(output_offset, 0); 270 output_[0]->SetFrameSlot(output_offset, 0);
272 output_offset -= kPointerSize; 271 output_offset -= kPointerSize;
273 } 272 }
274 273
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if (FLAG_trace_osr) { 341 if (FLAG_trace_osr) {
343 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ", 342 PrintF("[on-stack replacement translation %s: 0x%08" V8PRIxPTR " ",
344 ok ? "finished" : "aborted", 343 ok ? "finished" : "aborted",
345 reinterpret_cast<intptr_t>(function)); 344 reinterpret_cast<intptr_t>(function));
346 function->PrintName(); 345 function->PrintName();
347 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc()); 346 PrintF(" => pc=0x%0x]\n", output_[0]->GetPc());
348 } 347 }
349 } 348 }
350 349
351 350
351 void Deoptimizer::DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator,
352 int frame_index) {
353 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
354 unsigned height = iterator->Next();
355 unsigned height_in_bytes = height * kPointerSize;
356 if (FLAG_trace_deopt) {
357 PrintF(" translating arguments adaptor => height=%d\n", height_in_bytes);
358 }
359
360 unsigned fixed_frame_size = ArgumentsAdaptorFrameConstants::kFrameSize;
361 unsigned input_frame_size = input_->GetFrameSize();
362 unsigned output_frame_size = height_in_bytes + fixed_frame_size;
363
364 // Allocate and store the output frame description.
365 FrameDescription* output_frame =
366 new(output_frame_size) FrameDescription(output_frame_size, function);
367 output_frame->SetFrameType(StackFrame::ARGUMENTS_ADAPTOR);
368
369 // Arguments adaptor can not be topmost or bottommost.
370 ASSERT(frame_index > 0 && frame_index < output_count_ - 1);
371 ASSERT(output_[frame_index] == NULL);
372 output_[frame_index] = output_frame;
373
374 // The top address of the frame is computed from the previous
375 // frame's top and this frame's size.
376 uint32_t top_address;
377 top_address = output_[frame_index - 1]->GetTop() - output_frame_size;
378 output_frame->SetTop(top_address);
379
380 // Compute the incoming parameter translation.
381 int parameter_count = height;
382 unsigned output_offset = output_frame_size;
383 unsigned input_offset = input_frame_size;
384 for (int i = 0; i < parameter_count; ++i) {
385 output_offset -= kPointerSize;
386 DoTranslateCommand(iterator, frame_index, output_offset);
387 }
388 input_offset -= (parameter_count * kPointerSize);
389
390 // Read caller's PC from the previous frame.
391 output_offset -= kPointerSize;
392 input_offset -= kPointerSize;
393 intptr_t callers_pc = output_[frame_index - 1]->GetPc();
394 output_frame->SetFrameSlot(output_offset, callers_pc);
395 if (FLAG_trace_deopt) {
396 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's pc\n",
397 top_address + output_offset, output_offset, callers_pc);
398 }
399
400 // Read caller's FP from the previous frame, and set this frame's FP.
401 output_offset -= kPointerSize;
402 input_offset -= kPointerSize;
403 intptr_t value = output_[frame_index - 1]->GetFp();
404 output_frame->SetFrameSlot(output_offset, value);
405 intptr_t fp_value = top_address + output_offset;
406 output_frame->SetFp(fp_value);
407 if (FLAG_trace_deopt) {
408 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; caller's fp\n",
409 fp_value, output_offset, value);
410 }
411
412 // A marker value is used in place of the context.
413 output_offset -= kPointerSize;
414 input_offset -= kPointerSize;
415 intptr_t context = reinterpret_cast<intptr_t>(
416 Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
417 output_frame->SetFrameSlot(output_offset, context);
418 if (FLAG_trace_deopt) {
419 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; context (adaptor sentinel)\n",
420 top_address + output_offset, output_offset, context);
421 }
422
423 // The function was mentioned explicitly in the ARGUMENTS_ADAPTOR_FRAME.
424 output_offset -= kPointerSize;
425 input_offset -= kPointerSize;
426 value = reinterpret_cast<intptr_t>(function);
427 output_frame->SetFrameSlot(output_offset, value);
428 if (FLAG_trace_deopt) {
429 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; function\n",
430 top_address + output_offset, output_offset, value);
431 }
432
433 // Number of incoming arguments.
434 output_offset -= kPointerSize;
435 input_offset -= kPointerSize;
436 value = reinterpret_cast<uint32_t>(Smi::FromInt(height - 1));
437 output_frame->SetFrameSlot(output_offset, value);
438 if (FLAG_trace_deopt) {
439 PrintF(" 0x%08x: [top + %d] <- 0x%08x ; argc (%d)\n",
440 top_address + output_offset, output_offset, value, height - 1);
441 }
442
443 ASSERT(0 == output_offset);
444
445 Builtins* builtins = isolate_->builtins();
446 Code* adaptor_trampoline =
447 builtins->builtin(Builtins::kArgumentsAdaptorTrampoline);
448 uint32_t pc = reinterpret_cast<uint32_t>(
449 adaptor_trampoline->instruction_start() +
450 isolate_->heap()->arguments_adaptor_deopt_pc_offset()->value());
451 output_frame->SetPc(pc);
452 }
453
454
352 // This code is very similar to ia32/arm code, but relies on register names 455 // This code is very similar to ia32/arm code, but relies on register names
353 // (fp, sp) and how the frame is laid out. 456 // (fp, sp) and how the frame is laid out.
354 void Deoptimizer::DoComputeFrame(TranslationIterator* iterator, 457 void Deoptimizer::DoComputeJSFrame(TranslationIterator* iterator,
355 int frame_index) { 458 int frame_index) {
356 // Read the ast node id, function, and frame height for this output frame. 459 // Read the ast node id, function, and frame height for this output frame.
357 Translation::Opcode opcode =
358 static_cast<Translation::Opcode>(iterator->Next());
359 USE(opcode);
360 ASSERT(Translation::FRAME == opcode);
361 int node_id = iterator->Next(); 460 int node_id = iterator->Next();
362 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next())); 461 JSFunction* function = JSFunction::cast(ComputeLiteral(iterator->Next()));
363 unsigned height = iterator->Next(); 462 unsigned height = iterator->Next();
364 unsigned height_in_bytes = height * kPointerSize; 463 unsigned height_in_bytes = height * kPointerSize;
365 if (FLAG_trace_deopt) { 464 if (FLAG_trace_deopt) {
366 PrintF(" translating "); 465 PrintF(" translating ");
367 function->PrintName(); 466 function->PrintName();
368 PrintF(" => node=%d, height=%d\n", node_id, height_in_bytes); 467 PrintF(" => node=%d, height=%d\n", node_id, height_in_bytes);
369 } 468 }
370 469
371 // The 'fixed' part of the frame consists of the incoming parameters and 470 // The 'fixed' part of the frame consists of the incoming parameters and
372 // the part described by JavaScriptFrameConstants. 471 // the part described by JavaScriptFrameConstants.
373 unsigned fixed_frame_size = ComputeFixedSize(function); 472 unsigned fixed_frame_size = ComputeFixedSize(function);
374 unsigned input_frame_size = input_->GetFrameSize(); 473 unsigned input_frame_size = input_->GetFrameSize();
375 unsigned output_frame_size = height_in_bytes + fixed_frame_size; 474 unsigned output_frame_size = height_in_bytes + fixed_frame_size;
376 475
377 // Allocate and store the output frame description. 476 // Allocate and store the output frame description.
378 FrameDescription* output_frame = 477 FrameDescription* output_frame =
379 new(output_frame_size) FrameDescription(output_frame_size, function); 478 new(output_frame_size) FrameDescription(output_frame_size, function);
380 #ifdef DEBUG 479 output_frame->SetFrameType(StackFrame::JAVA_SCRIPT);
381 output_frame->SetKind(Code::FUNCTION);
382 #endif
383 480
384 bool is_bottommost = (0 == frame_index); 481 bool is_bottommost = (0 == frame_index);
385 bool is_topmost = (output_count_ - 1 == frame_index); 482 bool is_topmost = (output_count_ - 1 == frame_index);
386 ASSERT(frame_index >= 0 && frame_index < output_count_); 483 ASSERT(frame_index >= 0 && frame_index < output_count_);
387 ASSERT(output_[frame_index] == NULL); 484 ASSERT(output_[frame_index] == NULL);
388 output_[frame_index] = output_frame; 485 output_[frame_index] = output_frame;
389 486
390 // The top address for the bottommost output frame can be computed from 487 // The top address for the bottommost output frame can be computed from
391 // the input frame pointer and the output frame's height. For all 488 // the input frame pointer and the output frame's height. For all
392 // subsequent output frames, it can be computed from the previous one's 489 // subsequent output frames, it can be computed from the previous one's
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 864
768 ASSERT_EQ(table_entry_size_, masm()->pc_offset() - start); 865 ASSERT_EQ(table_entry_size_, masm()->pc_offset() - start);
769 } 866 }
770 __ bind(&done); 867 __ bind(&done);
771 } 868 }
772 869
773 #undef __ 870 #undef __
774 871
775 872
776 } } // namespace v8::internal 873 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/builtins-mips.cc ('k') | src/mips/frames-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698