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

Unified Diff: runtime/vm/flow_graph_compiler_x64.cc

Issue 10500005: More shared code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_compiler_x64.cc
===================================================================
--- runtime/vm/flow_graph_compiler_x64.cc (revision 8249)
+++ runtime/vm/flow_graph_compiler_x64.cc (working copy)
@@ -11,12 +11,9 @@
#include "vm/ast_printer.h"
#include "vm/code_descriptors.h"
#include "vm/code_generator.h"
-#include "vm/debugger.h"
#include "vm/disassembler.h"
#include "vm/il_printer.h"
-#include "vm/intrinsifier.h"
#include "vm/locations.h"
-#include "vm/longjump.h"
#include "vm/object_store.h"
#include "vm/parser.h"
#include "vm/stub_code.h"
@@ -26,10 +23,7 @@
DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables.");
DEFINE_FLAG(bool, trace_functions, false, "Trace entry of each function.");
DECLARE_FLAG(bool, enable_type_checks);
-DECLARE_FLAG(bool, intrinsify);
-DECLARE_FLAG(int, optimization_counter_threshold);
DECLARE_FLAG(bool, print_ast);
-DECLARE_FLAG(bool, report_usage_count);
DECLARE_FLAG(bool, code_comments);
@@ -63,20 +57,6 @@
block_order,
is_optimizing) {}
-
-void FlowGraphCompiler::Bailout(const char* reason) {
- const char* kFormat = "FlowGraphCompiler Bailout: %s %s.";
- const char* function_name = parsed_function().function().ToCString();
- intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
- char* chars = reinterpret_cast<char*>(
- Isolate::Current()->current_zone()->Allocate(len));
- OS::SNPrint(chars, len, kFormat, function_name, reason);
- const Error& error = Error::Handle(
- LanguageError::New(String::Handle(String::New(chars))));
- Isolate::Current()->long_jump_base()->Jump(1, error);
-}
-
-
#define __ assembler()->
@@ -560,56 +540,28 @@
}
-void FlowGraphCompiler::EmitInstanceCall(intptr_t cid,
- intptr_t token_index,
- intptr_t try_index,
- const String& function_name,
- intptr_t argument_count,
- const Array& argument_names,
- intptr_t checked_argument_count) {
- ICData& ic_data =
- ICData::ZoneHandle(ICData::New(parsed_function().function(),
- function_name,
- cid,
- checked_argument_count));
- const Array& arguments_descriptor =
- CodeGenerator::ArgumentsDescriptor(argument_count, argument_names);
+intptr_t FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label,
+ const ICData& ic_data,
+ const Array& arguments_descriptor,
+ intptr_t argument_count) {
__ LoadObject(RBX, ic_data);
__ LoadObject(R10, arguments_descriptor);
- uword label_address = 0;
- switch (checked_argument_count) {
- case 1:
- label_address = StubCode::OneArgCheckInlineCacheEntryPoint();
- break;
- case 2:
- label_address = StubCode::TwoArgsCheckInlineCacheEntryPoint();
- break;
- default:
- UNIMPLEMENTED();
- }
- ExternalLabel target_label("InlineCache", label_address);
- __ call(&target_label);
- AddCurrentDescriptor(PcDescriptors::kIcCall, cid, token_index, try_index);
+ __ call(target_label);
+ const intptr_t descr_offset = assembler()->CodeSize();
__ Drop(argument_count);
+ return descr_offset;
}
-
-void FlowGraphCompiler::EmitStaticCall(intptr_t token_index,
- intptr_t try_index,
- const Function& function,
- intptr_t argument_count,
- const Array& argument_names) {
- const Array& arguments_descriptor =
- CodeGenerator::ArgumentsDescriptor(argument_count, argument_names);
+intptr_t FlowGraphCompiler::EmitStaticCall(const Function& function,
+ const Array& arguments_descriptor,
+ intptr_t argument_count) {
__ LoadObject(RBX, function);
__ LoadObject(R10, arguments_descriptor);
-
- GenerateCall(token_index,
- try_index,
- &StubCode::CallStaticFunctionLabel(),
- PcDescriptors::kFuncCall);
+ __ call(&StubCode::CallStaticFunctionLabel());
+ const intptr_t descr_offset = assembler()->CodeSize();
__ Drop(argument_count);
+ return descr_offset;
}
@@ -945,45 +897,24 @@
}
-bool FlowGraphCompiler::CanOptimize() {
- return
- !FLAG_report_usage_count &&
- (FLAG_optimization_counter_threshold >= 0) &&
- !Isolate::Current()->debugger()->IsActive();
-}
-
-
-void FlowGraphCompiler::IntrinsifyGetter() {
+void FlowGraphCompiler::GenerateInlinedGetter(intptr_t offset) {
// TOS: return address.
// +1 : receiver.
// Sequence node has one return node, its input is load field node.
- const SequenceNode& sequence_node = *parsed_function().node_sequence();
- ASSERT(sequence_node.length() == 1);
- ASSERT(sequence_node.NodeAt(0)->IsReturnNode());
- const ReturnNode& return_node = *sequence_node.NodeAt(0)->AsReturnNode();
- ASSERT(return_node.value()->IsLoadInstanceFieldNode());
- const LoadInstanceFieldNode& load_node =
- *return_node.value()->AsLoadInstanceFieldNode();
__ movq(RAX, Address(RSP, 1 * kWordSize));
- __ movq(RAX, FieldAddress(RAX, load_node.field().Offset()));
+ __ movq(RAX, FieldAddress(RAX, offset));
__ ret();
}
-void FlowGraphCompiler::IntrinsifySetter() {
+void FlowGraphCompiler::GenerateInlinedSetter(intptr_t offset) {
// TOS: return address.
// +1 : value
// +2 : receiver.
// Sequence node has one store node and one return NULL node.
- const SequenceNode& sequence_node = *parsed_function().node_sequence();
- ASSERT(sequence_node.length() == 2);
- ASSERT(sequence_node.NodeAt(0)->IsStoreInstanceFieldNode());
- ASSERT(sequence_node.NodeAt(1)->IsReturnNode());
- const StoreInstanceFieldNode& store_node =
- *sequence_node.NodeAt(0)->AsStoreInstanceFieldNode();
__ movq(RAX, Address(RSP, 2 * kWordSize)); // Receiver.
__ movq(RBX, Address(RSP, 1 * kWordSize)); // Value.
- __ StoreIntoObject(RAX, FieldAddress(RAX, store_node.field().Offset()), RBX);
+ __ StoreIntoObject(RAX, FieldAddress(RAX, offset), RBX);
const Immediate raw_null =
Immediate(reinterpret_cast<intptr_t>(Object::null()));
__ movq(RAX, raw_null);
@@ -991,31 +922,6 @@
}
-// Returns 'true' if code generation for this function is complete, i.e.,
-// no fall-through to regular code is needed.
-bool FlowGraphCompiler::TryIntrinsify() {
- if (!CanOptimize()) return false;
- // Intrinsification skips arguments checks, therefore disable if in checked
- // mode.
- if (FLAG_intrinsify && !FLAG_trace_functions && !FLAG_enable_type_checks) {
- if ((parsed_function().function().kind() == RawFunction::kImplicitGetter)) {
- IntrinsifyGetter();
- return true;
- }
- if ((parsed_function().function().kind() == RawFunction::kImplicitSetter)) {
- IntrinsifySetter();
- return true;
- }
- }
- // Even if an intrinsified version of the function was successfully
- // generated, it may fall through to the non-intrinsified method body.
- if (!FLAG_trace_functions) {
- return Intrinsifier::Intrinsify(parsed_function().function(), assembler());
- }
- return false;
-}
-
-
void FlowGraphCompiler::CompileGraph() {
InitCompiler();
if (TryIntrinsify()) {
@@ -1130,10 +1036,6 @@
}
-void FlowGraphCompiler::FinalizeComments(const Code& code) {
- code.set_comments(assembler()->GetCodeComments());
-}
-
#undef __
} // namespace dart
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698