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

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

Issue 27802002: Disconnects code objects from infrequently used unoptimized functions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/globals.h" // Needed here to get TARGET_ARCH_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
11 #include "vm/compiler.h"
11 #include "vm/dart_entry.h" 12 #include "vm/dart_entry.h"
12 #include "vm/deopt_instructions.h" 13 #include "vm/deopt_instructions.h"
13 #include "vm/il_printer.h" 14 #include "vm/il_printer.h"
14 #include "vm/locations.h" 15 #include "vm/locations.h"
15 #include "vm/object_store.h" 16 #include "vm/object_store.h"
16 #include "vm/parser.h" 17 #include "vm/parser.h"
17 #include "vm/stack_frame.h" 18 #include "vm/stack_frame.h"
18 #include "vm/stub_code.h" 19 #include "vm/stub_code.h"
19 #include "vm/symbols.h" 20 #include "vm/symbols.h"
20 21
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 if (flow_graph().IsCompiledForOsr()) { 1092 if (flow_graph().IsCompiledForOsr()) {
1092 intptr_t extra_slots = StackSize() 1093 intptr_t extra_slots = StackSize()
1093 - flow_graph().num_stack_locals() 1094 - flow_graph().num_stack_locals()
1094 - flow_graph().num_copied_params(); 1095 - flow_graph().num_copied_params();
1095 ASSERT(extra_slots >= 0); 1096 ASSERT(extra_slots >= 0);
1096 __ EnterOsrFrame(extra_slots * kWordSize); 1097 __ EnterOsrFrame(extra_slots * kWordSize);
1097 } else { 1098 } else {
1098 ASSERT(StackSize() >= 0); 1099 ASSERT(StackSize() >= 0);
1099 __ EnterDartFrame(StackSize() * kWordSize); 1100 __ EnterDartFrame(StackSize() * kWordSize);
1100 } 1101 }
1102
1103 // TODO(zra): maybe do this only before we try to optimize?
1104 if (FLAG_collect_code) {
1105 // If we are collecting code, make sure this function still has a pointer
1106 // to the code object.
1107 // TODO(zra): Is it cheaper just to write the Function fields with the
1108 // code object without doing the test?
1109 Label is_connected;
1110 const Immediate& raw_null =
1111 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1112 const Register function_reg = EDI;
1113 __ LoadObject(function_reg, function);
1114 __ movl(EAX, FieldAddress(function_reg, Function::code_offset()));
1115 __ cmpl(EAX, raw_null);
1116 __ j(NOT_EQUAL, &is_connected, Assembler::kNearJump);
srdjan 2013/10/18 17:16:07 Add comment what you are doing: add the code objec
zra 2013/10/22 16:13:24 Code obsolete.
1117 __ movl(EAX, Address(EBP, kPcMarkerSlotFromFp * kWordSize));
1118 const intptr_t code_pc_dist =
1119 Instructions::HeaderSize() - Instructions::code_offset() +
1120 Assembler::kEntryPointToPcMarkerOffset;
srdjan 2013/10/18 17:16:07 Indent 4 chars the two lines above
zra 2013/10/22 16:13:24 Code obsolete
1121 __ movl(EAX, Address(EAX, -code_pc_dist));
1122 __ movl(FieldAddress(function_reg, Function::code_offset()), EAX);
1123 __ movl(
1124 FieldAddress(function_reg, Function::unoptimized_code_offset()), EAX);
1125 __ Bind(&is_connected);
1126 }
1101 } 1127 }
1102 1128
1103 1129
1104 void FlowGraphCompiler::CompileGraph() { 1130 void FlowGraphCompiler::CompileGraph() {
1105 InitCompiler(); 1131 InitCompiler();
1106 1132
1107 TryIntrinsify(); 1133 TryIntrinsify();
1108 1134
1109 EmitFrameEntry(); 1135 EmitFrameEntry();
1110 1136
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 __ j(ZERO, &call_target_function, Assembler::kNearJump); 1431 __ j(ZERO, &call_target_function, Assembler::kNearJump);
1406 __ cmpl(EDX, EAX); 1432 __ cmpl(EDX, EAX);
1407 __ j(NOT_EQUAL, &update, Assembler::kNearJump); 1433 __ j(NOT_EQUAL, &update, Assembler::kNearJump);
1408 1434
1409 __ Bind(&call_target_function); 1435 __ Bind(&call_target_function);
1410 // Call the target found in the cache. For a class id match, this is a 1436 // Call the target found in the cache. For a class id match, this is a
1411 // proper target for the given name and arguments descriptor. If the 1437 // proper target for the given name and arguments descriptor. If the
1412 // illegal class id was found, the target is a cache miss handler that can 1438 // illegal class id was found, the target is a cache miss handler that can
1413 // be invoked as a normal Dart function. 1439 // be invoked as a normal Dart function.
1414 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize)); 1440 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize));
1415 __ movl(EAX, FieldAddress(EAX, Function::code_offset())); 1441 __ movl(EBX, FieldAddress(EAX, Function::code_offset()));
1416 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); 1442 if (FLAG_collect_code) {
1443 // If we are collecting code, the code object may be null.
1444 Label is_compiled;
1445 const Immediate& raw_null =
1446 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1447 __ cmpl(EBX, raw_null);
1448 __ j(NOT_EQUAL, &is_compiled, Assembler::kNearJump);
1449 __ EnterStubFrame();
1450 __ pushl(EDX); // Preserve arguments descriptor array.
1451 __ pushl(ECX); // Preserve IC data object.
1452 __ pushl(EAX); // Pass function.
1453 __ CallRuntime(kCompileFunctionRuntimeEntry, 1);
1454 __ popl(EAX); // Restore function.
srdjan 2013/10/18 17:16:07 The argument can be modified in the callee, theref
zra 2013/10/22 16:13:24 At other call-sites of CompileFunction (e.g. aroun
1455 __ popl(ECX); // Restore IC data array.
1456 __ popl(EDX); // Restore arguments descriptor array.
1457 __ LeaveFrame();
1458 __ movl(EBX, FieldAddress(EAX, Function::code_offset()));
1459 __ Bind(&is_compiled);
1460 }
1461 __ movl(EAX, FieldAddress(EBX, Code::instructions_offset()));
1417 __ LoadObject(ECX, ic_data); 1462 __ LoadObject(ECX, ic_data);
1418 __ LoadObject(EDX, arguments_descriptor); 1463 __ LoadObject(EDX, arguments_descriptor);
1419 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); 1464 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
1420 __ call(EAX); 1465 __ call(EAX);
1421 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); 1466 AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos);
1422 RecordSafepoint(locs); 1467 RecordSafepoint(locs);
1423 AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); 1468 AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos);
1424 __ Drop(argument_count); 1469 __ Drop(argument_count);
1425 } 1470 }
1426 1471
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1915 __ movups(reg, Address(ESP, 0)); 1960 __ movups(reg, Address(ESP, 0));
1916 __ addl(ESP, Immediate(kFpuRegisterSize)); 1961 __ addl(ESP, Immediate(kFpuRegisterSize));
1917 } 1962 }
1918 1963
1919 1964
1920 #undef __ 1965 #undef __
1921 1966
1922 } // namespace dart 1967 } // namespace dart
1923 1968
1924 #endif // defined TARGET_ARCH_IA32 1969 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698