mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
6953144: Tiered compilation
Infrastructure for tiered compilation support (interpreter + c1 + c2) for 32 and 64 bit. Simple tiered policy implementation. Reviewed-by: kvn, never, phh, twisti
This commit is contained in:
parent
6e78f6cb4b
commit
2c66a6c3fd
104 changed files with 7720 additions and 1701 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,53 +25,91 @@
|
|||
// The CompilationPolicy selects which method (if any) should be compiled.
|
||||
// It also decides which methods must always be compiled (i.e., are never
|
||||
// interpreted).
|
||||
class CompileTask;
|
||||
class CompileQueue;
|
||||
|
||||
class CompilationPolicy : public CHeapObj {
|
||||
private:
|
||||
static CompilationPolicy* _policy;
|
||||
// Accumulated time
|
||||
static elapsedTimer _accumulated_time;
|
||||
|
||||
static bool _in_vm_startup;
|
||||
|
||||
public:
|
||||
virtual void method_invocation_event(methodHandle m, TRAPS) = 0;
|
||||
virtual void method_back_branch_event(methodHandle m, int branch_bci, int loop_top_bci, TRAPS) = 0;
|
||||
virtual int compilation_level(methodHandle m, int branch_bci) = 0;
|
||||
|
||||
void reset_counter_for_invocation_event(methodHandle method);
|
||||
void reset_counter_for_back_branch_event(methodHandle method);
|
||||
|
||||
public:
|
||||
static void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; }
|
||||
static void completed_vm_startup();
|
||||
static bool delayCompilationDuringStartup() { return _in_vm_startup; }
|
||||
|
||||
static bool mustBeCompiled(methodHandle m); // m must be compiled before executing it
|
||||
static bool canBeCompiled(methodHandle m); // m is allowed to be compiled
|
||||
static bool delay_compilation_during_startup() { return _in_vm_startup; }
|
||||
|
||||
// m must be compiled before executing it
|
||||
static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all);
|
||||
// m is allowed to be compiled
|
||||
static bool can_be_compiled(methodHandle m, int comp_level = CompLevel_all);
|
||||
static bool is_compilation_enabled();
|
||||
static void set_policy(CompilationPolicy* policy) { _policy = policy; }
|
||||
static CompilationPolicy* policy() { return _policy; }
|
||||
static CompilationPolicy* policy() { return _policy; }
|
||||
|
||||
// Profiling
|
||||
elapsedTimer* accumulated_time() { return &_accumulated_time; }
|
||||
void print_time() PRODUCT_RETURN;
|
||||
virtual int compiler_count(CompLevel comp_level) = 0;
|
||||
// main notification entry, return a pointer to an nmethod if the OSR is required,
|
||||
// returns NULL otherwise.
|
||||
virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, TRAPS) = 0;
|
||||
// safepoint() is called at the end of the safepoint
|
||||
virtual void do_safepoint_work() = 0;
|
||||
// reprofile request
|
||||
virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) = 0;
|
||||
// delay_compilation(method) can be called by any component of the runtime to notify the policy
|
||||
// that it's recommended to delay the complation of this method.
|
||||
virtual void delay_compilation(methodOop method) = 0;
|
||||
// disable_compilation() is called whenever the runtime decides to disable compilation of the
|
||||
// specified method.
|
||||
virtual void disable_compilation(methodOop method) = 0;
|
||||
// Select task is called by CompileBroker. The queue is guaranteed to have at least one
|
||||
// element and is locked. The function should select one and return it.
|
||||
virtual CompileTask* select_task(CompileQueue* compile_queue) = 0;
|
||||
// Tell the runtime if we think a given method is adequately profiled.
|
||||
virtual bool is_mature(methodOop method) = 0;
|
||||
// Do policy initialization
|
||||
virtual void initialize() = 0;
|
||||
};
|
||||
|
||||
class SimpleCompPolicy : public CompilationPolicy {
|
||||
// A base class for baseline policies.
|
||||
class NonTieredCompPolicy : public CompilationPolicy {
|
||||
int _compiler_count;
|
||||
protected:
|
||||
static void trace_frequency_counter_overflow(methodHandle m, int branch_bci, int bci);
|
||||
static void trace_osr_request(methodHandle method, nmethod* osr, int bci);
|
||||
static void trace_osr_completion(nmethod* osr_nm);
|
||||
void reset_counter_for_invocation_event(methodHandle method);
|
||||
void reset_counter_for_back_branch_event(methodHandle method);
|
||||
public:
|
||||
NonTieredCompPolicy() : _compiler_count(0) { }
|
||||
virtual int compiler_count(CompLevel comp_level);
|
||||
virtual void do_safepoint_work();
|
||||
virtual void reprofile(ScopeDesc* trap_scope, bool is_osr);
|
||||
virtual void delay_compilation(methodOop method);
|
||||
virtual void disable_compilation(methodOop method);
|
||||
virtual bool is_mature(methodOop method);
|
||||
virtual void initialize();
|
||||
virtual CompileTask* select_task(CompileQueue* compile_queue);
|
||||
virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, TRAPS);
|
||||
virtual void method_invocation_event(methodHandle m, TRAPS) = 0;
|
||||
virtual void method_back_branch_event(methodHandle m, int bci, TRAPS) = 0;
|
||||
};
|
||||
|
||||
class SimpleCompPolicy : public NonTieredCompPolicy {
|
||||
public:
|
||||
void method_invocation_event( methodHandle m, TRAPS);
|
||||
void method_back_branch_event(methodHandle m, int branch_bci, int loop_top_bci, TRAPS);
|
||||
int compilation_level(methodHandle m, int branch_bci);
|
||||
virtual void method_invocation_event(methodHandle m, TRAPS);
|
||||
virtual void method_back_branch_event(methodHandle m, int bci, TRAPS);
|
||||
};
|
||||
|
||||
// StackWalkCompPolicy - existing C2 policy
|
||||
|
||||
#ifdef COMPILER2
|
||||
class StackWalkCompPolicy : public CompilationPolicy {
|
||||
class StackWalkCompPolicy : public NonTieredCompPolicy {
|
||||
public:
|
||||
void method_invocation_event(methodHandle m, TRAPS);
|
||||
void method_back_branch_event(methodHandle m, int branch_bci, int loop_top_bci, TRAPS);
|
||||
int compilation_level(methodHandle m, int branch_bci);
|
||||
virtual void method_invocation_event(methodHandle m, TRAPS);
|
||||
virtual void method_back_branch_event(methodHandle m, int bci, TRAPS);
|
||||
|
||||
private:
|
||||
RFrame* findTopInlinableFrame(GrowableArray<RFrame*>* stack);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue