mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Lazily generate local var descriptors.
R=hausner@google.com Review URL: https://codereview.chromium.org//1128803002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45581 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
acfd54f53a
commit
3744661bc4
9 changed files with 48 additions and 8 deletions
|
@ -890,7 +890,7 @@ static void DisassembleCode(const Function& function, bool optimized) {
|
|||
ISL_Print("Variable Descriptors for function '%s' {\n",
|
||||
function_fullname);
|
||||
const LocalVarDescriptors& var_descriptors =
|
||||
LocalVarDescriptors::Handle(code.var_descriptors());
|
||||
LocalVarDescriptors::Handle(code.GetLocalVarDescriptors());
|
||||
intptr_t var_desc_length =
|
||||
var_descriptors.IsNull() ? 0 : var_descriptors.Length();
|
||||
String& var_name = String::Handle();
|
||||
|
@ -1129,6 +1129,24 @@ RawError* Compiler::CompileParsedFunction(
|
|||
}
|
||||
|
||||
|
||||
void Compiler::ComputeLocalVarDescriptors(const Code& code) {
|
||||
ASSERT(!code.is_optimized());
|
||||
const Function& function = Function::Handle(code.function());
|
||||
ParsedFunction* parsed_function = new ParsedFunction(
|
||||
Thread::Current(), Function::ZoneHandle(function.raw()));
|
||||
LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle();
|
||||
if (function.IsIrregexpFunction()) {
|
||||
UNREACHABLE(); // Special parsing needed, not yet implemented.
|
||||
} else {
|
||||
Parser::ParseFunction(parsed_function);
|
||||
parsed_function->AllocateVariables();
|
||||
var_descs =
|
||||
parsed_function->node_sequence()->scope()->GetVarDescriptors(function);
|
||||
}
|
||||
code.set_var_descriptors(var_descs);
|
||||
}
|
||||
|
||||
|
||||
RawError* Compiler::CompileAllFunctions(const Class& cls) {
|
||||
Thread* thread = Thread::Current();
|
||||
Zone* zone = thread->zone();
|
||||
|
|
|
@ -73,6 +73,9 @@ class Compiler : public AllStatic {
|
|||
// on compilation failure.
|
||||
static RawObject* EvaluateStaticInitializer(const Field& field);
|
||||
|
||||
// Generates local var descriptors and sets it in 'code'.
|
||||
static void ComputeLocalVarDescriptors(const Code& code);
|
||||
|
||||
// Eagerly compiles all functions in a class.
|
||||
//
|
||||
// Returns Error::null() if there is no compilation error.
|
||||
|
|
|
@ -478,7 +478,7 @@ void ActivationFrame::GetVarDescriptors() {
|
|||
}
|
||||
}
|
||||
var_descriptors_ =
|
||||
Code::Handle(function().unoptimized_code()).var_descriptors();
|
||||
Code::Handle(function().unoptimized_code()).GetLocalVarDescriptors();
|
||||
ASSERT(!var_descriptors_.IsNull());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ DEFINE_FLAG(bool, always_megamorphic_calls, false,
|
|||
"Instance call always as megamorphic.");
|
||||
DEFINE_FLAG(bool, trace_inlining_intervals, false,
|
||||
"Inlining interval diagnostics");
|
||||
DEFINE_FLAG(bool, eager_info_computation, false,
|
||||
"TRANSITIONAL: Eagerly compute local var descriptors.");
|
||||
DEFINE_FLAG(bool, enable_simd_inline, true,
|
||||
"Enable inlining of SIMD related method calls.");
|
||||
DEFINE_FLAG(int, min_optimization_counter_threshold, 5000,
|
||||
|
@ -926,6 +928,7 @@ void FlowGraphCompiler::FinalizeVarDescriptors(const Code& code) {
|
|||
}
|
||||
LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle();
|
||||
if (parsed_function().node_sequence() == NULL) {
|
||||
// TODO(srdjan): Implement lazy local var descriptors if Irregexp functions.
|
||||
ASSERT(flow_graph().IsIrregexpFunction());
|
||||
var_descs = LocalVarDescriptors::New(1);
|
||||
RawLocalVarDescriptors::VarInfo info;
|
||||
|
@ -936,9 +939,11 @@ void FlowGraphCompiler::FinalizeVarDescriptors(const Code& code) {
|
|||
info.set_index(parsed_function().current_context_var()->index());
|
||||
var_descs.SetVar(0, Symbols::CurrentContextVar(), &info);
|
||||
} else {
|
||||
var_descs =
|
||||
parsed_function_.node_sequence()->scope()->GetVarDescriptors(
|
||||
parsed_function_.function());
|
||||
if (FLAG_eager_info_computation) {
|
||||
var_descs =
|
||||
parsed_function_.node_sequence()->scope()->GetVarDescriptors(
|
||||
parsed_function_.function());
|
||||
}
|
||||
}
|
||||
code.set_var_descriptors(var_descs);
|
||||
}
|
||||
|
|
|
@ -12047,6 +12047,17 @@ Code::Comments::Comments(const Array& comments)
|
|||
}
|
||||
|
||||
|
||||
RawLocalVarDescriptors* Code::GetLocalVarDescriptors() const {
|
||||
LocalVarDescriptors& v = LocalVarDescriptors::Handle(var_descriptors());
|
||||
if (v.IsNull()) {
|
||||
const Function& f = Function::Handle(function());
|
||||
ASSERT(!f.IsIrregexpFunction()); // Not yet implemented.
|
||||
Compiler::ComputeLocalVarDescriptors(*this);
|
||||
}
|
||||
return v.raw();
|
||||
}
|
||||
|
||||
|
||||
void Code::set_state_bits(intptr_t bits) const {
|
||||
StoreNonPointer(&raw_ptr()->state_bits_, bits);
|
||||
}
|
||||
|
|
|
@ -4040,6 +4040,9 @@ class Code : public Object {
|
|||
StorePointer(&raw_ptr()->var_descriptors_, value.raw());
|
||||
}
|
||||
|
||||
// Will compute local var descriptors is necessary.
|
||||
RawLocalVarDescriptors* GetLocalVarDescriptors() const;
|
||||
|
||||
RawExceptionHandlers* exception_handlers() const {
|
||||
return raw_ptr()->exception_handlers_;
|
||||
}
|
||||
|
|
|
@ -2923,7 +2923,7 @@ TEST_CASE(PcDescriptorsCompressed) {
|
|||
const int kNumEntries = 6;
|
||||
// Add PcDescriptors to the code.
|
||||
PcDescriptors& descriptors = PcDescriptors::Handle();
|
||||
// PcDescritpors have no try-index.
|
||||
// PcDescriptors have no try-index.
|
||||
descriptors ^= PcDescriptors::New(kNumEntries, false);
|
||||
descriptors.AddDescriptor(0, 10, RawPcDescriptors::kOther, 1, 20, -1);
|
||||
descriptors.AddDescriptor(1, 20, RawPcDescriptors::kDeopt, 2, 30, -1);
|
||||
|
|
|
@ -213,7 +213,7 @@ static void SaveVars(Dart_IsolateId isolate_id,
|
|||
LocalVarDescriptors& var_desc = LocalVarDescriptors::Handle();
|
||||
for (intptr_t i = 0; i < num_frames; i++) {
|
||||
ActivationFrame* frame = stack->FrameAt(i);
|
||||
var_desc = frame->code().var_descriptors();
|
||||
var_desc = frame->code().GetLocalVarDescriptors();
|
||||
const char* var_str = SkipIndex(var_desc.ToCString());
|
||||
const char* function_str = String::Handle(
|
||||
frame->function().QualifiedUserVisibleName()).ToCString();
|
||||
|
|
|
@ -367,7 +367,7 @@ TEST_CASE(Service_LocalVarDescriptors) {
|
|||
EXPECT(!code_c.IsNull());
|
||||
|
||||
const LocalVarDescriptors& descriptors =
|
||||
LocalVarDescriptors::Handle(code_c.var_descriptors());
|
||||
LocalVarDescriptors::Handle(code_c.GetLocalVarDescriptors());
|
||||
// Generate an ID for this object.
|
||||
ObjectIdRing* ring = isolate->object_id_ring();
|
||||
intptr_t id = ring->GetIdForObject(descriptors.raw());
|
||||
|
|
Loading…
Reference in a new issue