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

Side by Side Diff: runtime/vm/code_generator.cc

Issue 10910119: Implement new optional parameters syntax in the vm (issue 4290). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/ast_printer.cc ('k') | runtime/vm/code_generator_test.cc » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/assembler_macros.h" 7 #include "vm/assembler_macros.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 } 1479 }
1480 1480
1481 1481
1482 // Copy optimized frame into the isolate buffer. 1482 // Copy optimized frame into the isolate buffer.
1483 // The first incoming argument is stored at the last entry in the 1483 // The first incoming argument is stored at the last entry in the
1484 // copied frame buffer. 1484 // copied frame buffer.
1485 static void CopyFrame(const Code& optimized_code, const StackFrame& frame) { 1485 static void CopyFrame(const Code& optimized_code, const StackFrame& frame) {
1486 const Function& function = Function::Handle(optimized_code.function()); 1486 const Function& function = Function::Handle(optimized_code.function());
1487 // Do not copy incoming arguments if there are optional arguments (they 1487 // Do not copy incoming arguments if there are optional arguments (they
1488 // are copied into local space at method entry). 1488 // are copied into local space at method entry).
1489 const intptr_t num_args = (function.num_optional_parameters() > 0) ? 1489 const intptr_t num_args =
1490 0 : function.num_fixed_parameters(); 1490 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters();
1491 // FP, PC-marker and return-address will be copied as well. 1491 // FP, PC-marker and return-address will be copied as well.
1492 const intptr_t frame_copy_size = 1492 const intptr_t frame_copy_size =
1493 1 // Deoptimized function's return address: caller_frame->pc(). 1493 1 // Deoptimized function's return address: caller_frame->pc().
1494 + ((frame.fp() - frame.sp()) / kWordSize) 1494 + ((frame.fp() - frame.sp()) / kWordSize)
1495 + 1 // PC marker. 1495 + 1 // PC marker.
1496 + 1 // Caller return address. 1496 + 1 // Caller return address.
1497 + num_args; 1497 + num_args;
1498 intptr_t* frame_copy = new intptr_t[frame_copy_size]; 1498 intptr_t* frame_copy = new intptr_t[frame_copy_size];
1499 ASSERT(frame_copy != NULL); 1499 ASSERT(frame_copy != NULL);
1500 // Include the return address of optimized code. 1500 // Include the return address of optimized code.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 // Compute the stack size of unoptimized frame 1547 // Compute the stack size of unoptimized frame
1548 const Array& deopt_info_array = 1548 const Array& deopt_info_array =
1549 Array::Handle(optimized_code.deopt_info_array()); 1549 Array::Handle(optimized_code.deopt_info_array());
1550 ASSERT(!deopt_info_array.IsNull()); 1550 ASSERT(!deopt_info_array.IsNull());
1551 DeoptInfo& deopt_info = DeoptInfo::Handle(); 1551 DeoptInfo& deopt_info = DeoptInfo::Handle();
1552 deopt_info ^= deopt_info_array.At(deopt_index); 1552 deopt_info ^= deopt_info_array.At(deopt_index);
1553 ASSERT(!deopt_info.IsNull()); 1553 ASSERT(!deopt_info.IsNull());
1554 // For functions with optional argument deoptimization info does not 1554 // For functions with optional argument deoptimization info does not
1555 // describe incoming arguments. 1555 // describe incoming arguments.
1556 const Function& function = Function::Handle(optimized_code.function()); 1556 const Function& function = Function::Handle(optimized_code.function());
1557 const intptr_t num_args = (function.num_optional_parameters() > 0) ? 1557 const intptr_t num_args =
1558 0 : function.num_fixed_parameters(); 1558 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters();
1559 intptr_t unoptimized_stack_size = 1559 intptr_t unoptimized_stack_size =
1560 + deopt_info.Length() - num_args 1560 + deopt_info.Length() - num_args
1561 - 2; // Subtract caller FP and PC. 1561 - 2; // Subtract caller FP and PC.
1562 return unoptimized_stack_size * kWordSize; 1562 return unoptimized_stack_size * kWordSize;
1563 } 1563 }
1564 END_LEAF_RUNTIME_ENTRY 1564 END_LEAF_RUNTIME_ENTRY
1565 1565
1566 1566
1567 1567
1568 static void DeoptimizeWithDeoptInfo(const Code& code, 1568 static void DeoptimizeWithDeoptInfo(const Code& code,
1569 const DeoptInfo& deopt_info, 1569 const DeoptInfo& deopt_info,
1570 const StackFrame& caller_frame) { 1570 const StackFrame& caller_frame) {
1571 const intptr_t len = deopt_info.Length(); 1571 const intptr_t len = deopt_info.Length();
1572 GrowableArray<DeoptInstr*> deopt_instructions(len); 1572 GrowableArray<DeoptInstr*> deopt_instructions(len);
1573 for (intptr_t i = 0; i < len; i++) { 1573 for (intptr_t i = 0; i < len; i++) {
1574 deopt_instructions.Add(DeoptInstr::Create(deopt_info.Instruction(i), 1574 deopt_instructions.Add(DeoptInstr::Create(deopt_info.Instruction(i),
1575 deopt_info.FromIndex(i))); 1575 deopt_info.FromIndex(i)));
1576 } 1576 }
1577 1577
1578 intptr_t* start = reinterpret_cast<intptr_t*>(caller_frame.sp() - kWordSize); 1578 intptr_t* start = reinterpret_cast<intptr_t*>(caller_frame.sp() - kWordSize);
1579 const Function& function = Function::Handle(code.function()); 1579 const Function& function = Function::Handle(code.function());
1580 const intptr_t num_args = (function.num_optional_parameters() > 0) ? 1580 const intptr_t num_args =
1581 0 : function.num_fixed_parameters(); 1581 function.HasOptionalParameters() ? 0 : function.num_fixed_parameters();
1582 intptr_t to_frame_size = 1582 intptr_t to_frame_size =
1583 1 // Deoptimized function's return address. 1583 1 // Deoptimized function's return address.
1584 + (caller_frame.fp() - caller_frame.sp()) / kWordSize 1584 + (caller_frame.fp() - caller_frame.sp()) / kWordSize
1585 + 3 // caller-fp, pc, pc-marker. 1585 + 3 // caller-fp, pc, pc-marker.
1586 + num_args; 1586 + num_args;
1587 DeoptimizationContext deopt_context(start, 1587 DeoptimizationContext deopt_context(start,
1588 to_frame_size, 1588 to_frame_size,
1589 Array::Handle(code.object_table()), 1589 Array::Handle(code.object_table()),
1590 num_args); 1590 num_args);
1591 for (intptr_t to_index = len - 1; to_index >= 0; to_index--) { 1591 for (intptr_t to_index = len - 1; to_index >= 0; to_index--) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 current->slot(), 1677 current->slot(),
1678 current->value()); 1678 current->value());
1679 } 1679 }
1680 1680
1681 delete current; 1681 delete current;
1682 } 1682 }
1683 } 1683 }
1684 1684
1685 1685
1686 } // namespace dart 1686 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/ast_printer.cc ('k') | runtime/vm/code_generator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698