[vm] Remove TokenStream, TokenValue, CompilerStats.

(CompilerStats timers have been replaced with the timeline events.)

Change-Id: Iddcb752c085de9762eb802371b6d2905fa608a76
Reviewed-on: https://dart-review.googlesource.com/c/79086
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2018-10-10 21:39:45 +00:00 committed by commit-bot@chromium.org
parent a933f42b9e
commit 662ff7f112
50 changed files with 28 additions and 2729 deletions

View file

@ -1618,16 +1618,8 @@ DEFINE_NATIVE_ENTRY(DeclarationMirror_location, 1) {
if (script.kind() == RawScript::kLibraryTag) break;
}
ASSERT(!script.IsNull());
const String& libname = String::Handle(zone, lib.name());
if (libname.Length() == 0) {
// No library declaration.
const String& uri = String::Handle(zone, script.url());
return CreateSourceLocation(uri, 1, 1);
}
const TokenStream& stream = TokenStream::Handle(zone, script.tokens());
TokenStream::Iterator tkit(zone, stream, TokenPosition::kMinSource);
if (tkit.CurrentTokenKind() == Token::kSCRIPTTAG) tkit.Advance();
token_pos = tkit.CurrentPosition();
const String& uri = String::Handle(zone, script.url());
return CreateSourceLocation(uri, 1, 1);
}
ASSERT(!script.IsNull());

View file

@ -91,7 +91,6 @@ import 'package:observatory/src/elements/subtypetestcache_ref.dart';
import 'package:observatory/src/elements/subtypetestcache_view.dart';
import 'package:observatory/src/elements/timeline_page.dart';
import 'package:observatory/src/elements/timeline/dashboard.dart';
import 'package:observatory/src/elements/token_stream_ref.dart';
import 'package:observatory/src/elements/type_arguments_ref.dart';
import 'package:observatory/src/elements/unknown_ref.dart';
import 'package:observatory/src/elements/unlinkedcall_ref.dart';
@ -192,7 +191,6 @@ export 'package:observatory/src/elements/subtypetestcache_ref.dart';
export 'package:observatory/src/elements/subtypetestcache_view.dart';
export 'package:observatory/src/elements/timeline_page.dart';
export 'package:observatory/src/elements/timeline/dashboard.dart';
export 'package:observatory/src/elements/token_stream_ref.dart';
export 'package:observatory/src/elements/type_arguments_ref.dart';
export 'package:observatory/src/elements/unknown_ref.dart';
export 'package:observatory/src/elements/unlinkedcall_ref.dart';
@ -297,7 +295,6 @@ Future initElements() async {
SubtypeTestCacheViewElement.tag.ensureRegistration();
TimelinePageElement.tag.ensureRegistration();
TimelineDashboardElement.tag.ensureRegistration();
TokenStreamRefElement.tag.ensureRegistration();
TypeArgumentsRefElement.tag.ensureRegistration();
UnknownObjectRefElement.tag.ensureRegistration();
UnlinkedCallRefElement.tag.ensureRegistration();

View file

@ -51,7 +51,6 @@ part 'src/models/objects/target.dart';
part 'src/models/objects/thread.dart';
part 'src/models/objects/timeline.dart';
part 'src/models/objects/timeline_event.dart';
part 'src/models/objects/token_stream.dart';
part 'src/models/objects/type_arguments.dart';
part 'src/models/objects/unknown.dart';
part 'src/models/objects/unlinked_call.dart';

View file

@ -23,7 +23,6 @@ import 'package:observatory/src/elements/script_ref.dart';
import 'package:observatory/src/elements/sentinel_value.dart';
import 'package:observatory/src/elements/singletargetcache_ref.dart';
import 'package:observatory/src/elements/subtypetestcache_ref.dart';
import 'package:observatory/src/elements/token_stream_ref.dart';
import 'package:observatory/src/elements/type_arguments_ref.dart';
import 'package:observatory/src/elements/unknown_ref.dart';
import 'package:observatory/src/elements/unlinkedcall_ref.dart';
@ -76,8 +75,6 @@ Element anyRef(M.IsolateRef isolate, ref, M.ObjectRepository objects,
return new SubtypeTestCacheRefElement(isolate, ref, queue: queue);
} else if (ref is M.TypeArgumentsRef) {
return new TypeArgumentsRefElement(isolate, ref, queue: queue);
} else if (ref is M.TokenStreamRef) {
return new TokenStreamRefElement(isolate, ref, queue: queue);
} else if (ref is M.UnknownObjectRef) {
return new UnknownObjectRefElement(isolate, ref, queue: queue);
} else if (ref is M.UnlinkedCallRef) {

View file

@ -1,60 +0,0 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:html';
import 'dart:async';
import 'package:observatory/models.dart' as M show IsolateRef, TokenStreamRef;
import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
import 'package:observatory/src/elements/helpers/tag.dart';
import 'package:observatory/src/elements/helpers/uris.dart';
class TokenStreamRefElement extends HtmlElement implements Renderable {
static const tag = const Tag<TokenStreamRefElement>('token-stream-ref');
RenderingScheduler<TokenStreamRefElement> _r;
Stream<RenderedEvent<TokenStreamRefElement>> get onRendered => _r.onRendered;
M.IsolateRef _isolate;
M.TokenStreamRef _token;
M.IsolateRef get isolate => _isolate;
M.TokenStreamRef get token => _token;
factory TokenStreamRefElement(M.IsolateRef isolate, M.TokenStreamRef token,
{RenderingQueue queue}) {
assert(isolate != null);
assert(token != null);
TokenStreamRefElement e = document.createElement(tag.name);
e._r = new RenderingScheduler<TokenStreamRefElement>(e, queue: queue);
e._isolate = isolate;
e._token = token;
return e;
}
TokenStreamRefElement.created() : super.created();
@override
void attached() {
super.attached();
_r.enable();
}
@override
void detached() {
super.detached();
_r.disable(notify: true);
children = <Element>[];
}
void render() {
final text = (_token.name == null || _token.name == '')
? 'TokenStream'
: _token.name;
children = <Element>[
new AnchorElement(href: Uris.inspect(_isolate, object: _token))
..text = text
];
}
}

View file

@ -1,10 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
part of models;
abstract class TokenStreamRef extends ObjectRef {
/// [optional]
String get name;
}

View file

@ -272,9 +272,6 @@ abstract class ServiceObject implements M.ObjectRef {
case 'SubtypeTestCache':
obj = new SubtypeTestCache._empty(owner);
break;
case 'TokenStream':
obj = new TokenStream._empty(owner);
break;
case 'UnlinkedCall':
obj = new UnlinkedCall._empty(owner);
break;
@ -4166,24 +4163,6 @@ class MegamorphicCache extends HeapObject implements M.MegamorphicCache {
}
}
class TokenStream extends HeapObject implements M.TokenStreamRef {
bool get immutable => true;
String privateKey;
TokenStream._empty(ServiceObjectOwner owner) : super._empty(owner);
void _update(Map map, bool mapIsRef) {
_upgradeCollection(map, isolate);
super._update(map, mapIsRef);
if (mapIsRef) {
return;
}
privateKey = map['privateKey'];
}
}
class CodeInstruction {
final int address;
final int pcOffset;

View file

@ -139,7 +139,6 @@ observatory_sources = [
"lib/src/elements/subtypetestcache_view.dart",
"lib/src/elements/timeline/dashboard.dart",
"lib/src/elements/timeline_page.dart",
"lib/src/elements/token_stream_ref.dart",
"lib/src/elements/top_retaining_instances.dart",
"lib/src/elements/type_arguments_ref.dart",
"lib/src/elements/unknown_ref.dart",
@ -194,7 +193,6 @@ observatory_sources = [
"lib/src/models/objects/thread.dart",
"lib/src/models/objects/timeline.dart",
"lib/src/models/objects/timeline_event.dart",
"lib/src/models/objects/token_stream.dart",
"lib/src/models/objects/type_arguments.dart",
"lib/src/models/objects/unknown.dart",
"lib/src/models/objects/unlinked_call.dart",

View file

@ -41,7 +41,6 @@ part 'mocks/objects/script.dart';
part 'mocks/objects/sentinel.dart';
part 'mocks/objects/source_location.dart';
part 'mocks/objects/target.dart';
part 'mocks/objects/token_stream.dart';
part 'mocks/objects/unknown.dart';
part 'mocks/objects/vm.dart';

View file

@ -1,11 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
part of mocks;
class TokenStreamRefMock implements M.TokenStreamRef {
final String id;
final String name;
const TokenStreamRefMock({this.id: 'tokenstream-id', this.name});
}

View file

@ -1,43 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:html';
import 'package:test/test.dart';
import 'package:observatory/src/elements/token_stream_ref.dart';
import '../mocks.dart';
main() {
TokenStreamRefElement.tag.ensureRegistration();
const isolate = const IsolateRefMock();
const token = const TokenStreamRefMock();
const token_named = const TokenStreamRefMock(name: 'name');
test('instantiation', () {
final e = new TokenStreamRefElement(isolate, token);
expect(e, isNotNull, reason: 'element correctly created');
expect(e.isolate, equals(isolate));
expect(e.token, equals(token));
});
group('elements', () {
test('created after attachment (no name)', () async {
final e = new TokenStreamRefElement(isolate, token);
document.body.append(e);
await e.onRendered.first;
expect(e.children.length, isNonZero, reason: 'has elements');
e.remove();
await e.onRendered.first;
expect(e.children.length, isZero, reason: 'is empty');
});
test('created after attachment (name)', () async {
final e = new TokenStreamRefElement(isolate, token_named);
document.body.append(e);
await e.onRendered.first;
expect(e.children.length, isNonZero, reason: 'has elements');
expect(e.innerHtml.contains(token_named.name), isTrue);
e.remove();
await e.onRendered.first;
expect(e.children.length, isZero, reason: 'is empty');
});
});
}

View file

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="dart.unittest" content="full-stack-traces">
<style>
.unittest-table { font-family:monospace; border:1px; }
.unittest-pass { background: #6b3;}
.unittest-fail { background: #d55;}
.unittest-error { background: #a11;}
</style>
</head>
<body>
<script type="text/javascript"
src="/root_dart/tools/testing/dart/test_controller.js"></script>
%TEST_SCRIPTS%
</body>
</html>

View file

@ -14,9 +14,9 @@
#include "platform/globals.h"
#include "vm/clustered_snapshot.h"
#include "vm/compiler_stats.h"
#include "vm/dart_api_impl.h"
#include "vm/stack_frame.h"
#include "vm/timer.h"
using dart::bin::File;
@ -111,72 +111,6 @@ BENCHMARK(CorelibCompileAll) {
benchmark->set_score(elapsed_time);
}
#ifndef PRODUCT
BENCHMARK(CorelibCompilerStats) {
bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary);
bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary);
bin::Builtin::SetNativeResolver(bin::Builtin::kCLILibrary);
TransitionNativeToVM transition(thread);
CompilerStats* stats = thread->isolate()->aggregate_compiler_stats();
ASSERT(stats != NULL);
stats->EnableBenchmark();
Timer timer(true, "Compiler stats compiling all of Core lib");
timer.Start();
const Error& error = Error::Handle(Library::CompileAll());
if (!error.IsNull()) {
OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s",
error.ToErrorCString());
}
timer.Stop();
int64_t elapsed_time = timer.TotalElapsedTime();
benchmark->set_score(elapsed_time);
}
BENCHMARK(Dart2JSCompilerStats) {
bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary);
bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary);
bin::Builtin::SetNativeResolver(bin::Builtin::kCLILibrary);
SetupDart2JSPackagePath();
char* dart_root = ComputeDart2JSPath(Benchmark::Executable());
char* script = NULL;
if (dart_root != NULL) {
HANDLESCOPE(thread);
script = OS::SCreate(NULL, "import '%s/pkg/compiler/lib/compiler.dart';",
dart_root);
Dart_Handle lib = TestCase::LoadTestScript(
script, reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver));
EXPECT_VALID(lib);
} else {
Dart_Handle lib = TestCase::LoadTestScript(
"import 'pkg/compiler/lib/compiler.dart';",
reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver));
EXPECT_VALID(lib);
}
CompilerStats* stats = thread->isolate()->aggregate_compiler_stats();
ASSERT(stats != NULL);
stats->EnableBenchmark();
Timer timer(true, "Compile all of dart2js benchmark");
timer.Start();
#if !defined(PRODUCT)
// Constant in product mode.
const bool old_flag = FLAG_background_compilation;
FLAG_background_compilation = false;
#endif
Dart_Handle result = Dart_CompileAll();
#if !defined(PRODUCT)
FLAG_background_compilation = old_flag;
#endif
EXPECT_VALID(result);
timer.Stop();
int64_t elapsed_time = timer.TotalElapsedTime();
benchmark->set_score(elapsed_time);
free(dart_root);
free(script);
}
#endif // !PRODUCT
// This file is created by the target //runtime/bin:gen_kernel_bytecode_dill
// which is depended on by run_vm_tests.
static char* ComputeGenKernelKernelPath(const char* arg) {

View file

@ -1150,160 +1150,6 @@ class FieldDeserializationCluster : public DeserializationCluster {
}
};
#if !defined(DART_PRECOMPILED_RUNTIME)
class LiteralTokenSerializationCluster : public SerializationCluster {
public:
LiteralTokenSerializationCluster() : SerializationCluster("LiteralToken") {}
virtual ~LiteralTokenSerializationCluster() {}
void Trace(Serializer* s, RawObject* object) {
RawLiteralToken* token = LiteralToken::RawCast(object);
objects_.Add(token);
RawObject** from = token->from();
RawObject** to = token->to();
for (RawObject** p = from; p <= to; p++) {
s->Push(*p);
}
}
void WriteAlloc(Serializer* s) {
s->WriteCid(kLiteralTokenCid);
intptr_t count = objects_.length();
s->WriteUnsigned(count);
for (intptr_t i = 0; i < count; i++) {
RawLiteralToken* token = objects_[i];
s->AssignRef(token);
}
}
void WriteFill(Serializer* s) {
intptr_t count = objects_.length();
for (intptr_t i = 0; i < count; i++) {
RawLiteralToken* token = objects_[i];
RawObject** from = token->from();
RawObject** to = token->to();
for (RawObject** p = from; p <= to; p++) {
s->WriteRef(*p);
}
s->Write<int32_t>(token->ptr()->kind_);
}
}
private:
GrowableArray<RawLiteralToken*> objects_;
};
#endif // !DART_PRECOMPILED_RUNTIME
class LiteralTokenDeserializationCluster : public DeserializationCluster {
public:
LiteralTokenDeserializationCluster() {}
virtual ~LiteralTokenDeserializationCluster() {}
void ReadAlloc(Deserializer* d) {
start_index_ = d->next_index();
PageSpace* old_space = d->heap()->old_space();
intptr_t count = d->ReadUnsigned();
for (intptr_t i = 0; i < count; i++) {
d->AssignRef(
AllocateUninitialized(old_space, LiteralToken::InstanceSize()));
}
stop_index_ = d->next_index();
}
void ReadFill(Deserializer* d) {
bool is_vm_object = d->isolate() == Dart::vm_isolate();
for (intptr_t id = start_index_; id < stop_index_; id++) {
RawLiteralToken* token = reinterpret_cast<RawLiteralToken*>(d->Ref(id));
Deserializer::InitializeHeader(
token, kLiteralTokenCid, LiteralToken::InstanceSize(), is_vm_object);
RawObject** from = token->from();
RawObject** to = token->to();
for (RawObject** p = from; p <= to; p++) {
*p = d->ReadRef();
}
token->ptr()->kind_ = static_cast<Token::Kind>(d->Read<int32_t>());
}
}
};
#if !defined(DART_PRECOMPILED_RUNTIME)
class TokenStreamSerializationCluster : public SerializationCluster {
public:
TokenStreamSerializationCluster() : SerializationCluster("TokenStream") {}
virtual ~TokenStreamSerializationCluster() {}
void Trace(Serializer* s, RawObject* object) {
RawTokenStream* stream = TokenStream::RawCast(object);
objects_.Add(stream);
RawObject** from = stream->from();
RawObject** to = stream->to();
for (RawObject** p = from; p <= to; p++) {
s->Push(*p);
}
}
void WriteAlloc(Serializer* s) {
s->WriteCid(kTokenStreamCid);
intptr_t count = objects_.length();
s->WriteUnsigned(count);
for (intptr_t i = 0; i < count; i++) {
RawTokenStream* stream = objects_[i];
s->AssignRef(stream);
}
}
void WriteFill(Serializer* s) {
intptr_t count = objects_.length();
for (intptr_t i = 0; i < count; i++) {
RawTokenStream* stream = objects_[i];
RawObject** from = stream->from();
RawObject** to = stream->to();
for (RawObject** p = from; p <= to; p++) {
s->WriteRef(*p);
}
}
}
private:
GrowableArray<RawTokenStream*> objects_;
};
#endif // !DART_PRECOMPILED_RUNTIME
class TokenStreamDeserializationCluster : public DeserializationCluster {
public:
TokenStreamDeserializationCluster() {}
virtual ~TokenStreamDeserializationCluster() {}
void ReadAlloc(Deserializer* d) {
start_index_ = d->next_index();
PageSpace* old_space = d->heap()->old_space();
intptr_t count = d->ReadUnsigned();
for (intptr_t i = 0; i < count; i++) {
d->AssignRef(
AllocateUninitialized(old_space, TokenStream::InstanceSize()));
}
stop_index_ = d->next_index();
}
void ReadFill(Deserializer* d) {
bool is_vm_object = d->isolate() == Dart::vm_isolate();
for (intptr_t id = start_index_; id < stop_index_; id++) {
RawTokenStream* stream = reinterpret_cast<RawTokenStream*>(d->Ref(id));
Deserializer::InitializeHeader(stream, kTokenStreamCid,
TokenStream::InstanceSize(), is_vm_object);
RawObject** from = stream->from();
RawObject** to = stream->to();
for (RawObject** p = from; p <= to; p++) {
*p = d->ReadRef();
}
}
}
};
#if !defined(DART_PRECOMPILED_RUNTIME)
class ScriptSerializationCluster : public SerializationCluster {
public:
@ -4722,10 +4568,6 @@ SerializationCluster* Serializer::NewClusterForClass(intptr_t cid) {
return new (Z) RedirectionDataSerializationCluster();
case kFieldCid:
return new (Z) FieldSerializationCluster();
case kLiteralTokenCid:
return new (Z) LiteralTokenSerializationCluster();
case kTokenStreamCid:
return new (Z) TokenStreamSerializationCluster();
case kScriptCid:
return new (Z) ScriptSerializationCluster();
case kLibraryCid:
@ -5247,10 +5089,6 @@ DeserializationCluster* Deserializer::ReadCluster() {
return new (Z) RedirectionDataDeserializationCluster();
case kFieldCid:
return new (Z) FieldDeserializationCluster();
case kLiteralTokenCid:
return new (Z) LiteralTokenDeserializationCluster();
case kTokenStreamCid:
return new (Z) TokenStreamDeserializationCluster();
case kScriptCid:
return new (Z) ScriptDeserializationCluster();
case kLibraryCid:
@ -5678,8 +5516,6 @@ class SeedVMIsolateVisitor : public ClassVisitor, public FunctionVisitor {
AddSeed(kernel_program_info_.metadata_payloads());
AddSeed(kernel_program_info_.metadata_mappings());
AddSeed(kernel_program_info_.constants());
} else {
AddSeed(script_.tokens());
}
}

View file

@ -1643,7 +1643,6 @@ void Precompiler::DropScriptData() {
Library& lib = Library::Handle(Z);
Array& scripts = Array::Handle(Z);
Script& script = Script::Handle(Z);
const TokenStream& null_tokens = TokenStream::Handle(Z);
for (intptr_t i = 0; i < libraries_.Length(); i++) {
lib ^= libraries_.At(i);
scripts = lib.LoadedScripts();
@ -1651,7 +1650,6 @@ void Precompiler::DropScriptData() {
script ^= scripts.At(j);
script.set_compile_time_constants(Array::null_array());
script.set_source(String::null_string());
script.set_tokens(null_tokens);
}
}
}
@ -2227,13 +2225,10 @@ void PrecompileParsedFunctionHelper::FinalizeCompilation(
const Function& function = parsed_function()->function();
Zone* const zone = thread()->zone();
CSTAT_TIMER_SCOPE(thread(), codefinalizer_timer);
// CreateDeoptInfo uses the object pool and needs to be done before
// FinalizeCode.
const Array& deopt_info_array =
Array::Handle(zone, graph_compiler->CreateDeoptInfo(assembler));
INC_STAT(thread(), total_code_size,
deopt_info_array.Length() * sizeof(uword));
// Allocates instruction object. Since this occurs only at safepoint,
// there can be no concurrent access to the instruction page.
const Code& code = Code::Handle(Code::FinalizeCode(
@ -2284,7 +2279,6 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
#ifndef PRODUCT
TimelineStream* compiler_timeline = Timeline::GetCompilerStream();
#endif // !PRODUCT
CSTAT_TIMER_SCOPE(thread(), codegen_timer);
HANDLESCOPE(thread());
// We may reattempt compilation if the function needs to be assembled using
@ -2307,10 +2301,7 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
CompilerState compiler_state(thread());
// TimerScope needs an isolate to be properly terminated in case of a
// LongJump.
{
CSTAT_TIMER_SCOPE(thread(), graphbuilder_timer);
ic_data_array = new (zone) ZoneGrowableArray<const ICData*>();
#ifndef PRODUCT
TimelineDurationScope tds(thread(), compiler_timeline,
@ -2343,7 +2334,6 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
TimelineDurationScope tds(thread(), compiler_timeline,
"OptimizationPasses");
#endif // !PRODUCT
CSTAT_TIMER_SCOPE(thread(), graphoptimizer_timer);
pass_state.inline_id_to_function.Add(&function);
// We do not add the token position now because we don't know the
@ -2381,7 +2371,6 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
pass_state.inline_id_to_token_pos, pass_state.caller_inline_id,
ic_data_array, function_stats);
{
CSTAT_TIMER_SCOPE(thread(), graphcompiler_timer);
#ifndef PRODUCT
TimelineDurationScope tds(thread(), compiler_timeline, "CompileGraph");
#endif // !PRODUCT
@ -2471,17 +2460,9 @@ static RawError* PrecompileFunctionHelper(Precompiler* precompiler,
function.ToFullyQualifiedCString(), function.token_pos().Pos(),
(function.end_token_pos().Pos() - function.token_pos().Pos()));
}
INC_STAT(thread, num_functions_compiled, 1);
if (optimized) {
INC_STAT(thread, num_functions_optimized, 1);
}
{
HANDLESCOPE(thread);
const int64_t num_tokens_before = STAT_VALUE(thread, num_tokens_consumed);
pipeline->ParseFunction(parsed_function);
const int64_t num_tokens_after = STAT_VALUE(thread, num_tokens_consumed);
INC_STAT(thread, num_func_tokens_compiled,
num_tokens_after - num_tokens_before);
}
PrecompileParsedFunctionHelper helper(precompiler, parsed_function,

View file

@ -975,12 +975,6 @@ void FlowGraphCompiler::FinalizeExceptionHandlers(const Code& code) {
const ExceptionHandlers& handlers = ExceptionHandlers::Handle(
exception_handlers_list_->FinalizeExceptionHandlers(code.PayloadStart()));
code.set_exception_handlers(handlers);
if (FLAG_compiler_stats) {
Thread* thread = Thread::Current();
INC_STAT(thread, total_code_size,
ExceptionHandlers::InstanceSize(handlers.num_entries()));
INC_STAT(thread, total_code_size, handlers.num_entries() * sizeof(uword));
}
}
void FlowGraphCompiler::FinalizePcDescriptors(const Code& code) {
@ -1096,20 +1090,15 @@ void FlowGraphCompiler::FinalizeStaticCallTargetsTable(const Code& code) {
}
}
code.set_static_calls_target_table(targets);
INC_STAT(Thread::Current(), total_code_size,
targets.Length() * sizeof(uword));
}
void FlowGraphCompiler::FinalizeCodeSourceMap(const Code& code) {
const Array& inlined_id_array =
Array::Handle(zone(), code_source_map_builder_->InliningIdToFunction());
INC_STAT(Thread::Current(), total_code_size,
inlined_id_array.Length() * sizeof(uword));
code.set_inlined_id_to_function(inlined_id_array);
const CodeSourceMap& map =
CodeSourceMap::Handle(code_source_map_builder_->Finalize());
INC_STAT(Thread::Current(), total_code_size, map.Length() * sizeof(uint8_t));
code.set_code_source_map(map);
#if defined(DEBUG)

View file

@ -23,7 +23,6 @@
#include "vm/longjump.h"
#include "vm/object.h"
#include "vm/object_store.h"
#include "vm/timer.h"
namespace dart {
@ -94,7 +93,6 @@ DEFINE_FLAG(bool,
false,
"Enable inlining annotations");
DECLARE_FLAG(bool, compiler_stats);
DECLARE_FLAG(int, max_deoptimization_counter_threshold);
DECLARE_FLAG(bool, print_flow_graph);
DECLARE_FLAG(bool, print_flow_graph_optimized);
@ -560,7 +558,6 @@ static void ReplaceParameterStubs(Zone* zone,
FlowGraph* caller_graph,
InlinedCallData* call_data,
const TargetInfo* target_info) {
CSTAT_TIMER_SCOPE(Thread::Current(), graphinliner_subst_timer);
const bool is_polymorphic = call_data->call->IsPolymorphicInstanceCall();
ASSERT(is_polymorphic == (target_info != NULL));
FlowGraph* callee_graph = call_data->callee_graph;
@ -944,7 +941,6 @@ class CallSiteInliner : public ValueObject {
bool in_cache;
ParsedFunction* parsed_function;
{
CSTAT_TIMER_SCOPE(thread(), graphinliner_parse_timer);
parsed_function = GetParsedFunction(function, &in_cache);
if (!function.CanBeInlined()) {
// As a side effect of parsing the function, it may be marked
@ -977,7 +973,6 @@ class CallSiteInliner : public ValueObject {
caller_graph_->max_block_id() + 1,
entry_kind == Code::EntryKind::kUnchecked);
{
CSTAT_TIMER_SCOPE(thread(), graphinliner_build_timer);
callee_graph = builder.BuildGraph();
CalleeGraphValidator::Validate(callee_graph);
@ -1061,7 +1056,6 @@ class CallSiteInliner : public ValueObject {
block_scheduler.AssignEdgeWeights();
{
CSTAT_TIMER_SCOPE(thread(), graphinliner_ssa_timer);
// Compute SSA on the callee graph, catching bailouts.
callee_graph->ComputeSSA(caller_graph_->max_virtual_register_number(),
param_stubs);
@ -1077,7 +1071,6 @@ class CallSiteInliner : public ValueObject {
}
{
CSTAT_TIMER_SCOPE(thread(), graphinliner_opt_timer);
// TODO(fschneider): Improve suppression of speculative inlining.
// Deopt-ids overlap between caller and callee.
if (FLAG_precompiled_mode) {
@ -1313,7 +1306,6 @@ class CallSiteInliner : public ValueObject {
}
void InlineCall(InlinedCallData* call_data) {
CSTAT_TIMER_SCOPE(Thread::Current(), graphinliner_subst_timer);
FlowGraph* callee_graph = call_data->callee_graph;
TargetEntryInstr* callee_entry =
callee_graph->graph_entry()->normal_entry();

View file

@ -276,7 +276,6 @@ void CompilerPass::RunPipeline(PipelineMode mode,
}
COMPILER_PASS(ComputeSSA, {
CSTAT_TIMER_SCOPE(state->thread, ssa_timer);
// Transform to SSA (virtual register 0 and no inlining arguments).
flow_graph->ComputeSSA(0, NULL);
});
@ -289,7 +288,6 @@ COMPILER_PASS(SetOuterInliningId,
{ FlowGraphInliner::SetInliningId(flow_graph, 0); });
COMPILER_PASS(Inlining, {
CSTAT_TIMER_SCOPE(state->thread, graphinliner_timer);
FlowGraphInliner inliner(
flow_graph, &state->inline_id_to_function, &state->inline_id_to_token_pos,
&state->caller_inline_id, state->speculative_policy, state->precompiler);

View file

@ -1007,9 +1007,6 @@ bool ConstantEvaluator::GetCachedConstant(intptr_t kernel_offset,
// is running, and thus change the value of 'compile_time_constants';
// do not assert that 'compile_time_constants' has not changed.
constants.Release();
if (FLAG_compiler_stats && is_present) {
++H.thread()->compiler_stats()->num_const_cache_hits;
}
return is_present;
}

View file

@ -533,13 +533,10 @@ RawCode* CompileParsedFunctionHelper::FinalizeCompilation(
const Function& function = parsed_function()->function();
Zone* const zone = thread()->zone();
CSTAT_TIMER_SCOPE(thread(), codefinalizer_timer);
// CreateDeoptInfo uses the object pool and needs to be done before
// FinalizeCode.
const Array& deopt_info_array =
Array::Handle(zone, graph_compiler->CreateDeoptInfo(assembler));
INC_STAT(thread(), total_code_size,
deopt_info_array.Length() * sizeof(uword));
// Allocates instruction object. Since this occurs only at safepoint,
// there can be no concurrent access to the instruction page.
Code& code = Code::Handle(Code::FinalizeCode(
@ -711,7 +708,6 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
Zone* const zone = thread()->zone();
NOT_IN_PRODUCT(TimelineStream* compiler_timeline =
Timeline::GetCompilerStream());
CSTAT_TIMER_SCOPE(thread(), codegen_timer);
HANDLESCOPE(thread());
// We may reattempt compilation if the function needs to be assembled using
@ -737,11 +733,7 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
CompilerState compiler_state(thread());
// TimerScope needs an isolate to be properly terminated in case of a
// LongJump.
{
CSTAT_TIMER_SCOPE(thread(), graphbuilder_timer);
if (optimized()) {
// In background compilation the deoptimization counter may have
// already reached the limit.
@ -808,7 +800,6 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
if (optimized()) {
NOT_IN_PRODUCT(TimelineDurationScope tds(thread(), compiler_timeline,
"OptimizationPasses"));
CSTAT_TIMER_SCOPE(thread(), graphoptimizer_timer);
pass_state.inline_id_to_function.Add(&function);
// We do not add the token position now because we don't know the
@ -835,7 +826,6 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
pass_state.inline_id_to_token_pos, pass_state.caller_inline_id,
ic_data_array);
{
CSTAT_TIMER_SCOPE(thread(), graphcompiler_timer);
NOT_IN_PRODUCT(TimelineDurationScope tds(thread(), compiler_timeline,
"CompileGraph"));
graph_compiler.CompileGraph();
@ -932,20 +922,12 @@ static RawObject* CompileFunctionHelper(CompilationPipeline* pipeline,
function.ToFullyQualifiedCString(),
function.token_pos().ToCString(), token_size);
}
INC_STAT(thread, num_functions_compiled, 1);
if (optimized) {
INC_STAT(thread, num_functions_optimized, 1);
}
// Makes sure no classes are loaded during parsing in background.
const intptr_t loading_invalidation_gen_at_start =
isolate->loading_invalidation_gen();
{
HANDLESCOPE(thread);
const int64_t num_tokens_before = STAT_VALUE(thread, num_tokens_consumed);
pipeline->ParseFunction(parsed_function);
const int64_t num_tokens_after = STAT_VALUE(thread, num_tokens_consumed);
INC_STAT(thread, num_func_tokens_compiled,
num_tokens_after - num_tokens_before);
}
CompileParsedFunctionHelper helper(parsed_function, optimized, osr_id);
@ -1709,14 +1691,8 @@ void BackgroundCompiler::Run() {
}
while (running_ && !function.IsNull() && !isolate_->IsTopLevelParsing()) {
// Check that we have aggregated and cleared the stats.
ASSERT(thread->compiler_stats()->IsCleared());
Compiler::CompileOptimizedFunction(thread, function,
Compiler::kNoOSRDeoptId);
#ifndef PRODUCT
Isolate* isolate = thread->isolate();
isolate->aggregate_compiler_stats()->Add(*thread->compiler_stats());
thread->compiler_stats()->Clear();
#endif // PRODUCT
QueueElement* qelem = NULL;
{

View file

@ -1,308 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/compiler_stats.h"
#include "vm/flags.h"
#include "vm/log.h"
#include "vm/object_graph.h"
#include "vm/object_store.h"
#include "vm/timer.h"
namespace dart {
DEFINE_FLAG(bool, compiler_stats, false, "Compiler stat counters.");
DEFINE_FLAG(bool,
compiler_benchmark,
false,
"Compiler stat counters for benchmark.");
class TokenStreamVisitor : public ObjectVisitor {
public:
explicit TokenStreamVisitor(CompilerStats* compiler_stats)
: obj_(Object::Handle()), stats_(compiler_stats) {}
void VisitObject(RawObject* raw_obj) {
if (raw_obj->IsPseudoObject()) {
return; // Cannot be wrapped in handles.
}
obj_ = raw_obj;
if (obj_.GetClassId() == TokenStream::kClassId) {
TokenStream::Iterator tkit(
Thread::Current()->zone(), TokenStream::Cast(obj_),
TokenPosition::kMinSource, TokenStream::Iterator::kNoNewlines);
Token::Kind kind = tkit.CurrentTokenKind();
while (kind != Token::kEOS) {
++stats_->num_tokens_total;
tkit.Advance();
kind = tkit.CurrentTokenKind();
}
}
}
private:
Object& obj_;
CompilerStats* stats_;
};
CompilerStats::CompilerStats(Isolate* isolate)
: isolate_(isolate),
#define INITIALIZE_TIMER(timer_name, description) timer_name(true, description),
STAT_TIMERS(INITIALIZE_TIMER)
#undef INITIALIZE_TIMER
#define INITIALIZE_COUNTERS(counter_name) counter_name(0),
STAT_COUNTERS(INITIALIZE_COUNTERS)
#undef INITIALIZE_COUNTERS
text(NULL),
use_benchmark_output(false) {
}
#ifndef PRODUCT
// Used to aggregate stats. Must be atomic.
void CompilerStats::Add(const CompilerStats& other) {
#define ADD_TOTAL(timer_name, literal) timer_name.AddTotal(other.timer_name);
STAT_TIMERS(ADD_TOTAL)
#undef ADD_TOTAL
#define ADD_COUNTER(counter_name) \
AtomicOperations::IncrementInt64By(&counter_name, other.counter_name);
STAT_COUNTERS(ADD_COUNTER)
#undef ADD_COUNTER
}
void CompilerStats::Clear() {
#define CLEAR_TIMER(timer_name, literal) timer_name.Reset();
STAT_TIMERS(CLEAR_TIMER)
#undef CLEAR_TIMER
#define CLEAR_COUNTER(counter_name) counter_name = 0;
STAT_COUNTERS(CLEAR_COUNTER)
#undef CLEAR_COUNTER
}
bool CompilerStats::IsCleared() const {
#define CHECK_TIMERS(timer_name, literal) \
if (!timer_name.IsReset()) return false;
STAT_TIMERS(CHECK_TIMERS)
#undef CHECK_TIMERS
#define CHECK_COUNTERS(counter_name) \
if (counter_name != 0) return false;
STAT_COUNTERS(CHECK_COUNTERS)
#undef CHECK_COUNTERS
return true;
}
// This function is used as a callback in the log object to which the
// compiler stats are printed. It will be called only once, to print
// the accumulated text when all of the compiler stats values are
// added to the log.
static void PrintToStats(const char* format, ...) PRINTF_ATTRIBUTE(1, 2);
static void PrintToStats(const char* format, ...) {
Thread* thread = Thread::Current();
Isolate* isolate = thread->isolate();
CompilerStats* stats = isolate->aggregate_compiler_stats();
Zone* zone = thread->zone();
ASSERT(stats != NULL);
va_list args;
va_start(args, format);
stats->text = zone->VPrint(format, args);
va_end(args);
}
void CompilerStats::Update() {
// Traverse the heap and compute number of tokens in all
// TokenStream objects.
num_tokens_total = 0;
{
HeapIterationScope iteration(Thread::Current());
TokenStreamVisitor visitor(this);
iteration.IterateObjects(&visitor);
iteration.IterateVMIsolateObjects(&visitor);
}
}
void CompilerStats::EnableBenchmark() {
FLAG_compiler_stats = true;
use_benchmark_output = true;
}
// Generate output for Golem benchmark harness. If the output format
// changes, the parsing function in Golem must be updated.
char* CompilerStats::BenchmarkOutput() {
Update();
Log log(PrintToStats);
LogBlock lb(Thread::Current(), &log);
log.Print("==== Compiler Stats for isolate (%" Pd64 ") '%s' ====\n",
static_cast<int64_t>(isolate_->main_port()), isolate_->name());
log.Print("NumberOfTokens: %" Pd64 "\n", num_tokens_total);
log.Print("NumClassesParsed: %" Pd64 "\n", num_classes_parsed);
log.Print("NumFunctionsCompiled: %" Pd64 "\n", num_functions_compiled);
log.Print("NumFunctionsOptimized: %" Pd64 "\n", num_functions_optimized);
log.Print("NumFunctionsParsed: %" Pd64 "\n", num_functions_parsed);
// Scanner stats.
int64_t scan_usecs = scanner_timer.TotalElapsedTime();
int64_t scan_speed =
scan_usecs > 0 ? 1000 * num_tokens_scanned / scan_usecs : 0;
log.Print("NumTokensScanned: %" Pd64 " tokens\n", num_tokens_scanned);
log.Print("ScannerTime: %" Pd64 " ms\n", scan_usecs / 1000);
log.Print("ScannerSpeed: %" Pd64 " tokens/ms\n", scan_speed);
// Parser stats.
int64_t parse_usecs = parser_timer.TotalElapsedTime();
int64_t parse_speed =
parse_usecs > 0 ? 1000 * num_tokens_consumed / parse_usecs : 0;
log.Print("NumTokensParsed: %" Pd64 " tokens\n", num_tokens_consumed);
log.Print("ParserTime: %" Pd64 " ms\n", parse_usecs / 1000);
log.Print("ParserSpeed: %" Pd64 " tokens/ms\n", parse_speed);
// Compiler stats.
int64_t codegen_usecs = codegen_timer.TotalElapsedTime();
int64_t compile_usecs = scan_usecs + parse_usecs + codegen_usecs;
int64_t compile_speed =
compile_usecs > 0 ? (1000 * num_func_tokens_compiled / compile_usecs) : 0;
log.Print("NumTokensCompiled: %" Pd64 " tokens\n", num_func_tokens_compiled);
log.Print("CompilerTime: %" Pd64 " ms\n", compile_usecs / 1000);
log.Print("CompilerSpeed: %" Pd64 " tokens/ms\n", compile_speed);
log.Print("CodeSize: %" Pd64 " KB\n", total_code_size / 1024);
int64_t code_density =
total_instr_size > 0
? (num_func_tokens_compiled * 1024) / total_instr_size
: 0;
log.Print("CodeDensity: %" Pd64 " tokens/KB\n", code_density);
log.Print("InstrSize: %" Pd64 " KB\n", total_instr_size / 1024);
log.Flush();
char* benchmark_text = text;
text = NULL;
return benchmark_text;
}
char* CompilerStats::PrintToZone() {
if (!FLAG_compiler_stats) {
return NULL;
} else if (use_benchmark_output) {
return BenchmarkOutput();
}
Update();
Log log(PrintToStats);
LogBlock lb(Thread::Current(), &log);
log.Print("==== Compiler Stats for isolate (%" Pd64 ") '%s' ====\n",
static_cast<int64_t>(isolate_->main_port()), isolate_->name());
log.Print("Number of tokens: %" Pd64 "\n", num_tokens_total);
log.Print("Source length: %" Pd64 " characters\n", src_length);
log.Print("Number of source tokens: %" Pd64 "\n", num_tokens_scanned);
int64_t num_local_functions =
GrowableObjectArray::Handle(isolate_->object_store()->closure_functions())
.Length();
log.Print("==== Parser stats:\n");
log.Print("Total tokens consumed: %" Pd64 "\n", num_tokens_consumed);
log.Print("Classes parsed: %" Pd64 "\n", num_classes_parsed);
log.Print(" Tokens consumed: %" Pd64 "\n", num_class_tokens);
log.Print("Functions parsed: %" Pd64 "\n", num_functions_parsed);
log.Print(" Tokens consumed: %" Pd64 "\n", num_func_tokens_compiled);
log.Print("Impl getter funcs: %" Pd64 "\n", num_implicit_final_getters);
log.Print("Impl method extractors: %" Pd64 "\n", num_method_extractors);
log.Print("Local functions: %" Pd64 "\n", num_local_functions);
log.Print("Consts cached: %" Pd64 "\n", num_cached_consts);
log.Print("Consts cache hits: %" Pd64 "\n", num_const_cache_hits);
log.Print("Consts calcuated: %" Pd64 "\n", num_execute_const);
int64_t scan_usecs = scanner_timer.TotalElapsedTime();
log.Print("Scanner time: %" Pd64 " ms\n", scan_usecs / 1000);
int64_t scan_speed =
scan_usecs > 0 ? 1000 * num_tokens_consumed / scan_usecs : 0;
log.Print("Scanner speed: %" Pd64 " tokens/ms\n", scan_speed);
int64_t parse_usecs = parser_timer.TotalElapsedTime();
int64_t parse_speed =
parse_usecs > 0 ? 1000 * num_tokens_consumed / parse_usecs : 0;
log.Print("Parser time: %" Pd64 " ms\n", parse_usecs / 1000);
log.Print("Parser speed: %" Pd64 " tokens/ms\n", parse_speed);
int64_t codegen_usecs = codegen_timer.TotalElapsedTime();
log.Print("==== Backend stats:\n");
log.Print("Code gen. time: %" Pd64 " ms\n", codegen_usecs / 1000);
int64_t graphbuilder_usecs = graphbuilder_timer.TotalElapsedTime();
log.Print(" Graph builder: %" Pd64 " ms\n",
graphbuilder_usecs / 1000);
int64_t ssa_usecs = ssa_timer.TotalElapsedTime();
log.Print(" Graph SSA: %" Pd64 " ms\n", ssa_usecs / 1000);
int64_t graphinliner_usecs = graphinliner_timer.TotalElapsedTime();
log.Print(" Graph inliner: %" Pd64 " ms\n",
graphinliner_usecs / 1000);
int64_t graphinliner_parse_usecs =
graphinliner_parse_timer.TotalElapsedTime();
log.Print(" Parsing: %" Pd64 " ms\n",
graphinliner_parse_usecs / 1000);
int64_t graphinliner_build_usecs =
graphinliner_build_timer.TotalElapsedTime();
log.Print(" Building: %" Pd64 " ms\n",
graphinliner_build_usecs / 1000);
int64_t graphinliner_ssa_usecs = graphinliner_ssa_timer.TotalElapsedTime();
log.Print(" SSA: %" Pd64 " ms\n",
graphinliner_ssa_usecs / 1000);
int64_t graphinliner_opt_usecs = graphinliner_opt_timer.TotalElapsedTime();
log.Print(" Optimization: %" Pd64 " ms\n",
graphinliner_opt_usecs / 1000);
int64_t graphinliner_subst_usecs =
graphinliner_subst_timer.TotalElapsedTime();
log.Print(" Substitution: %" Pd64 " ms\n",
graphinliner_subst_usecs / 1000);
int64_t graphoptimizer_usecs = graphoptimizer_timer.TotalElapsedTime();
log.Print(" Graph optimizer: %" Pd64 " ms\n",
(graphoptimizer_usecs - graphinliner_usecs) / 1000);
int64_t graphcompiler_usecs = graphcompiler_timer.TotalElapsedTime();
log.Print(" Graph compiler: %" Pd64 " ms\n",
graphcompiler_usecs / 1000);
int64_t codefinalizer_usecs = codefinalizer_timer.TotalElapsedTime();
log.Print(" Code finalizer: %" Pd64 " ms\n",
codefinalizer_usecs / 1000);
log.Print("==== Compiled code stats:\n");
int64_t compile_usecs = scan_usecs + parse_usecs + codegen_usecs;
int64_t compile_speed =
compile_usecs > 0 ? (1000 * num_func_tokens_compiled / compile_usecs) : 0;
log.Print("Functions parsed: %" Pd64 "\n", num_functions_parsed);
log.Print("Functions compiled: %" Pd64 "\n", num_functions_compiled);
log.Print(" optimized: %" Pd64 "\n", num_functions_optimized);
log.Print("Compiler time: %" Pd64 " ms\n", compile_usecs / 1000);
log.Print("Tokens compiled: %" Pd64 "\n", num_func_tokens_compiled);
log.Print("Compilation speed: %" Pd64 " tokens/ms\n", compile_speed);
int64_t code_density =
total_instr_size > 0
? (num_func_tokens_compiled * 1024) / total_instr_size
: 0;
log.Print("Code density: %" Pd64 " tokens per KB\n", code_density);
log.Print("Code size: %" Pd64 " KB\n", total_code_size / 1024);
log.Print(" Instr size: %" Pd64 " KB\n", total_instr_size / 1024);
log.Print(" Pc Desc size: %" Pd64 " KB\n", pc_desc_size / 1024);
log.Print(" VarDesc size: %" Pd64 " KB\n", vardesc_size / 1024);
log.Flush();
char* stats_text = text;
text = NULL;
return stats_text;
}
#endif // !PRODUCT
} // namespace dart

View file

@ -1,142 +0,0 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_VM_COMPILER_STATS_H_
#define RUNTIME_VM_COMPILER_STATS_H_
#include "platform/atomic.h"
#include "vm/allocation.h"
#include "vm/flags.h"
#include "vm/isolate.h"
#include "vm/timer.h"
namespace dart {
DECLARE_FLAG(bool, compiler_stats);
DECLARE_FLAG(bool, compiler_benchmark);
#define STAT_TIMERS(V) \
V(parser_timer, "parser timer") \
V(scanner_timer, "scanner timer") \
V(codegen_timer, "codegen timer") \
V(graphbuilder_timer, "flow graph builder timer") \
V(ssa_timer, "flow graph SSA timer") \
V(graphinliner_timer, "flow graph inliner timer") \
V(graphinliner_parse_timer, "inliner parsing timer") \
V(graphinliner_build_timer, "inliner building timer") \
V(graphinliner_ssa_timer, "inliner SSA timer") \
V(graphinliner_opt_timer, "inliner optimization timer") \
V(graphinliner_subst_timer, "inliner substitution timer") \
V(graphoptimizer_timer, "flow graph optimizer timer") \
V(graphcompiler_timer, "flow graph compiler timer") \
V(codefinalizer_timer, "code finalization timer")
#define STAT_COUNTERS(V) \
V(num_tokens_total) \
V(num_tokens_scanned) \
V(num_tokens_consumed) \
V(num_cached_consts) \
V(num_const_cache_hits) \
V(num_execute_const) \
V(num_classes_parsed) \
V(num_class_tokens) \
V(num_functions_parsed) \
V(num_functions_compiled) \
V(num_functions_optimized) \
V(num_func_tokens_compiled) \
V(num_implicit_final_getters) \
V(num_method_extractors) \
V(src_length) \
V(total_code_size) \
V(total_instr_size) \
V(pc_desc_size) \
V(vardesc_size)
class CompilerStats {
public:
explicit CompilerStats(Isolate* isolate);
~CompilerStats() {}
Isolate* isolate_;
// We could use STAT_TIMERS and STAT_COUNTERS to declare fields, but then
// we would be losing the comments.
Timer parser_timer; // Cumulative runtime of parser.
Timer scanner_timer; // Cumulative runtime of scanner.
Timer codegen_timer; // Cumulative runtime of code generator.
Timer graphbuilder_timer; // Included in codegen_timer.
Timer ssa_timer; // Included in codegen_timer.
Timer graphinliner_timer; // Included in codegen_timer.
Timer graphinliner_parse_timer; // Included in codegen_timer.
Timer graphinliner_build_timer; // Included in codegen_timer.
Timer graphinliner_ssa_timer; // Included in codegen_timer.
Timer graphinliner_opt_timer; // Included in codegen_timer.
Timer graphinliner_subst_timer; // Included in codegen_timer.
Timer graphoptimizer_timer; // Included in codegen_timer.
Timer graphcompiler_timer; // Included in codegen_timer.
Timer codefinalizer_timer; // Included in codegen_timer.
ALIGN8 int64_t num_tokens_total; // Isolate + VM isolate.
ALIGN8 int64_t num_tokens_scanned;
ALIGN8 int64_t num_tokens_consumed;
ALIGN8 int64_t num_cached_consts;
ALIGN8 int64_t num_const_cache_hits;
ALIGN8 int64_t num_execute_const;
ALIGN8 int64_t num_classes_parsed;
ALIGN8 int64_t num_class_tokens;
ALIGN8 int64_t num_functions_parsed; // Num parsed functions.
ALIGN8 int64_t num_functions_compiled; // Num unoptimized compilations.
ALIGN8 int64_t num_functions_optimized; // Num optimized compilations.
ALIGN8 int64_t num_func_tokens_compiled;
ALIGN8 int64_t num_implicit_final_getters;
ALIGN8 int64_t num_method_extractors;
ALIGN8 int64_t src_length; // Total number of characters in source.
ALIGN8 int64_t total_code_size; // Bytes allocated for code and meta info.
ALIGN8 int64_t total_instr_size; // Total size of generated code in bytes.
ALIGN8 int64_t pc_desc_size;
ALIGN8 int64_t vardesc_size;
char* text;
bool use_benchmark_output;
void EnableBenchmark();
char* BenchmarkOutput();
char* PrintToZone();
// Used to aggregate stats.
void Add(const CompilerStats& other);
void Clear();
bool IsCleared() const;
private:
// Update stats that are computed, e.g. token count.
void Update();
};
// Make increment atomic in case it occurs in parallel with aggregation from
// other thread.
#define INC_STAT(thread, counter, incr) \
if (FLAG_support_compiler_stats && FLAG_compiler_stats) { \
AtomicOperations::IncrementInt64By(&(thread)->compiler_stats()->counter, \
(incr)); \
}
#define STAT_VALUE(thread, counter) \
((FLAG_support_compiler_stats && FLAG_compiler_stats) \
? (thread)->compiler_stats()->counter \
: 0)
#define CSTAT_TIMER_SCOPE(thr, t) \
TimerScope timer(FLAG_support_compiler_stats&& FLAG_compiler_stats, \
(FLAG_support_compiler_stats && FLAG_compiler_stats) \
? &((thr)->compiler_stats()->t) \
: NULL, \
thr);
} // namespace dart
#endif // RUNTIME_VM_COMPILER_STATS_H_

View file

@ -48,7 +48,6 @@
#include "vm/symbols.h"
#include "vm/tags.h"
#include "vm/thread_registry.h"
#include "vm/timer.h"
#include "vm/unicode.h"
#include "vm/uri.h"
#include "vm/version.h"

View file

@ -2482,21 +2482,6 @@ void Debugger::PauseException(const Instance& exc) {
ClearCachedStackTraces();
}
static TokenPosition LastTokenOnLine(Zone* zone,
const TokenStream& tokens,
TokenPosition pos) {
TokenStream::Iterator iter(zone, tokens, pos,
TokenStream::Iterator::kAllTokens);
ASSERT(iter.IsValid());
TokenPosition last_pos = pos;
while ((iter.CurrentTokenKind() != Token::kNEWLINE) &&
(iter.CurrentTokenKind() != Token::kEOS)) {
last_pos = iter.CurrentPosition();
iter.Advance();
}
return last_pos;
}
// Returns the best fit token position for a breakpoint.
//
// Takes a range of tokens [requested_token_pos, last_token_pos] and
@ -2635,8 +2620,8 @@ TokenPosition Debugger::ResolveBreakpointPos(const Function& func,
end_of_line_pos = begin_pos;
}
} else {
const TokenStream& tokens = TokenStream::Handle(zone, script.tokens());
end_of_line_pos = LastTokenOnLine(zone, tokens, begin_pos);
UNREACHABLE();
end_of_line_pos = TokenPosition::kNoSource;
}
uword lowest_pc_offset = kUwordMax;
@ -3864,13 +3849,7 @@ bool Debugger::IsAtAsyncJump(ActivationFrame* top_frame) {
}
return false;
}
const TokenStream& tokens = TokenStream::Handle(zone, script.tokens());
TokenStream::Iterator iter(zone, tokens, top_frame->TokenPos());
if ((iter.CurrentTokenKind() == Token::kIDENT) &&
((iter.CurrentLiteral() == Symbols::Await().raw()) ||
(iter.CurrentLiteral() == Symbols::YieldKw().raw()))) {
return true;
}
UNREACHABLE();
}
return false;
}

View file

@ -163,7 +163,6 @@ constexpr bool kDartPrecompiledRuntime = false;
"Stress test async stack traces") \
P(strong, bool, true, "Enable strong mode.") \
P(sync_async, bool, true, "Start `async` functions synchronously.") \
R(support_compiler_stats, false, bool, true, "Support compiler stats.") \
R(support_disassembler, false, bool, true, "Support the disassembler.") \
R(support_il_printer, false, bool, true, "Support the IL printer.") \
C(support_reload, false, false, bool, true, "Support isolate reload.") \

View file

@ -6,7 +6,6 @@
#include "platform/address_sanitizer.h"
#include "platform/assert.h"
#include "vm/compiler_stats.h"
#include "vm/heap/become.h"
#include "vm/heap/compactor.h"
#include "vm/heap/marker.h"

View file

@ -12,7 +12,6 @@
#include "vm/class_finalizer.h"
#include "vm/code_observers.h"
#include "vm/compiler/jit/compiler.h"
#include "vm/compiler_stats.h"
#include "vm/dart_api_message.h"
#include "vm/dart_api_state.h"
#include "vm/dart_entry.h"
@ -49,7 +48,6 @@
#include "vm/thread_registry.h"
#include "vm/timeline.h"
#include "vm/timeline_analysis.h"
#include "vm/timer.h"
#include "vm/visitor.h"
namespace dart {
@ -1240,7 +1238,6 @@ void Isolate::DoneLoading() {
lib.SetLoaded();
}
}
TokenStream::CloseSharedTokenList(this);
}
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
@ -1871,19 +1868,6 @@ void Isolate::Shutdown() {
// Don't allow anymore dart code to execution on this isolate.
thread->ClearStackLimit();
// First, perform higher-level cleanup that may need to allocate.
{
// Ensure we have a zone and handle scope so that we can call VM functions.
StackZone stack_zone(thread);
HandleScope handle_scope(thread);
// Write compiler stats data if enabled.
if (FLAG_support_compiler_stats && FLAG_compiler_stats &&
!Isolate::IsVMInternalIsolate(this)) {
OS::PrintErr("%s", aggregate_compiler_stats()->PrintToZone());
}
}
// Remove this isolate from the list *before* we start tearing it down, to
// avoid exposing it in a state of decay.
RemoveIsolateFromList(this);

View file

@ -21,7 +21,6 @@
#include "vm/random.h"
#include "vm/tags.h"
#include "vm/thread.h"
#include "vm/timer.h"
#include "vm/token_position.h"
namespace dart {
@ -31,7 +30,6 @@ class ApiState;
class BackgroundCompiler;
class Capability;
class CodeIndexTable;
class CompilerStats;
class Debugger;
class DeoptContext;
class ExternalTypedData;
@ -510,11 +508,6 @@ class Isolate : public BaseIsolate {
void PrintJSON(JSONStream* stream, bool ref = true);
#endif
// Mutator thread is used to aggregate compiler stats.
CompilerStats* aggregate_compiler_stats() {
return mutator_thread()->compiler_stats();
}
#if !defined(PRODUCT)
VMTagCounters* vm_tag_counters() { return &vm_tag_counters_; }

File diff suppressed because it is too large Load diff

View file

@ -421,8 +421,6 @@ class Object {
static RawClass* signature_data_class() { return signature_data_class_; }
static RawClass* redirection_data_class() { return redirection_data_class_; }
static RawClass* field_class() { return field_class_; }
static RawClass* literal_token_class() { return literal_token_class_; }
static RawClass* token_stream_class() { return token_stream_class_; }
static RawClass* script_class() { return script_class_; }
static RawClass* library_class() { return library_class_; }
static RawClass* namespace_class() { return namespace_class_; }
@ -688,8 +686,6 @@ class Object {
static RawClass* signature_data_class_; // Class of SignatureData vm obj.
static RawClass* redirection_data_class_; // Class of RedirectionData vm obj.
static RawClass* field_class_; // Class of the Field vm object.
static RawClass* literal_token_class_; // Class of LiteralToken vm object.
static RawClass* token_stream_class_; // Class of the TokenStream vm object.
static RawClass* script_class_; // Class of the Script vm object.
static RawClass* library_class_; // Class of the Library vm object.
static RawClass* namespace_class_; // Class of Namespace vm object.
@ -3584,118 +3580,6 @@ class Field : public Object {
friend class FieldSerializationCluster;
};
class LiteralToken : public Object {
public:
Token::Kind kind() const { return raw_ptr()->kind_; }
RawString* literal() const { return raw_ptr()->literal_; }
RawObject* value() const { return raw_ptr()->value_; }
static intptr_t InstanceSize() {
return RoundedAllocationSize(sizeof(RawLiteralToken));
}
static RawLiteralToken* New();
static RawLiteralToken* New(Token::Kind kind, const String& literal);
private:
void set_kind(Token::Kind kind) const {
StoreNonPointer(&raw_ptr()->kind_, kind);
}
void set_literal(const String& literal) const;
void set_value(const Object& value) const;
FINAL_HEAP_OBJECT_IMPLEMENTATION(LiteralToken, Object);
friend class Class;
};
class TokenStream : public Object {
public:
RawGrowableObjectArray* TokenObjects() const;
void SetTokenObjects(const GrowableObjectArray& value) const;
RawExternalTypedData* GetStream() const;
void SetStream(const ExternalTypedData& stream) const;
RawString* GenerateSource() const;
RawString* GenerateSource(TokenPosition start, TokenPosition end) const;
intptr_t ComputeSourcePosition(TokenPosition tok_pos) const;
RawString* PrivateKey() const;
static const intptr_t kBytesPerElement = 1;
static const intptr_t kMaxElements = kSmiMax / kBytesPerElement;
static intptr_t InstanceSize() {
return RoundedAllocationSize(sizeof(RawTokenStream));
}
static RawTokenStream* New(intptr_t length);
static RawTokenStream* New(const String& source,
const String& private_key,
bool use_shared_tokens);
static void OpenSharedTokenList(Isolate* isolate);
static void CloseSharedTokenList(Isolate* isolate);
// The class Iterator encapsulates iteration over the tokens
// in a TokenStream object.
class Iterator : ValueObject {
public:
enum StreamType { kNoNewlines, kAllTokens };
Iterator(Zone* zone,
const TokenStream& tokens,
TokenPosition token_pos,
Iterator::StreamType stream_type = kNoNewlines);
void SetStream(const TokenStream& tokens, TokenPosition token_pos);
bool IsValid() const;
inline Token::Kind CurrentTokenKind() const { return cur_token_kind_; }
Token::Kind LookaheadTokenKind(intptr_t num_tokens);
TokenPosition CurrentPosition() const;
void SetCurrentPosition(TokenPosition token_pos);
void Advance();
RawObject* CurrentToken() const;
RawString* CurrentLiteral() const;
RawString* MakeLiteralToken(const Object& obj) const;
private:
// Read token from the token stream (could be a simple token or an index
// into the token objects array for IDENT or literal tokens).
intptr_t ReadToken() {
int64_t value = stream_.ReadUnsigned();
ASSERT((value >= 0) && (value <= kIntptrMax));
return static_cast<intptr_t>(value);
}
TokenStream& tokens_;
ExternalTypedData& data_;
ReadStream stream_;
Array& token_objects_;
Object& obj_;
intptr_t cur_token_pos_;
Token::Kind cur_token_kind_;
intptr_t cur_token_obj_index_;
Iterator::StreamType stream_type_;
};
private:
void SetPrivateKey(const String& value) const;
static RawTokenStream* New();
static void DataFinalizer(void* isolate_callback_data,
Dart_WeakPersistentHandle handle,
void* peer);
FINAL_HEAP_OBJECT_IMPLEMENTATION(TokenStream, Object);
friend class Class;
};
class Script : public Object {
public:
RawString* url() const { return raw_ptr()->url_; }
@ -3705,7 +3589,6 @@ class Script : public Object {
RawString* resolved_url() const { return raw_ptr()->resolved_url_; }
bool HasSource() const;
RawString* Source() const;
RawString* GenerateSource() const; // Generates source code from Tokenstream.
RawGrowableObjectArray* GenerateLineNumberArray() const;
RawScript::Kind kind() const {
return static_cast<RawScript::Kind>(raw_ptr()->kind_);
@ -3734,11 +3617,6 @@ class Script : public Object {
RawTypedData* kernel_string_offsets() const;
RawTokenStream* tokens() const {
ASSERT(kind() != RawScript::kKernelTag);
return raw_ptr()->tokens_;
}
RawTypedData* line_starts() const;
void set_line_starts(const TypedData& value) const;
@ -3749,8 +3627,6 @@ class Script : public Object {
RawArray* yield_positions() const;
void Tokenize(const String& private_key, bool use_shared_tokens = true) const;
RawLibrary* FindLibrary() const;
RawString* GetLine(intptr_t line_number,
Heap::Space space = Heap::kNew) const;
@ -3776,9 +3652,6 @@ class Script : public Object {
TokenPosition* first_token_index,
TokenPosition* last_token_index) const;
int32_t SourceFingerprint() const;
int32_t SourceFingerprint(TokenPosition start, TokenPosition end) const;
static intptr_t InstanceSize() {
return RoundedAllocationSize(sizeof(RawScript));
}
@ -3797,7 +3670,6 @@ class Script : public Object {
void set_source(const String& value) const;
void set_kind(RawScript::Kind value) const;
void set_load_timestamp(int64_t value) const;
void set_tokens(const TokenStream& value) const;
RawArray* debug_positions() const;
static RawScript* New();

View file

@ -402,26 +402,6 @@ void Field::PrintJSONImpl(JSONStream* stream, bool ref) const {
}
}
void LiteralToken::PrintJSONImpl(JSONStream* stream, bool ref) const {
Object::PrintJSONImpl(stream, ref);
}
void TokenStream::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);
AddCommonObjectProperties(&jsobj, "Object", ref);
// TODO(johnmccutchan): Generate a stable id. TokenStreams hang off
// a Script object but do not have a back reference to generate a stable id.
jsobj.AddServiceId(*this);
if (ref) {
return;
}
const String& private_key = String::Handle(PrivateKey());
jsobj.AddProperty("privateKey", private_key);
// TODO(johnmccutchan): Add support for printing LiteralTokens and add
// them to members array.
JSONArray members(&jsobj, "members");
}
// See also Dart_ScriptGetTokenInfo.
void Script::PrintJSONImpl(JSONStream* stream, bool ref) const {
JSONObject jsobj(stream);

View file

@ -122,8 +122,6 @@ class ObjectPointerVisitor;
RW(Class, async_star_stream_controller) \
RW(Array, library_load_error_table) \
RW(Array, unique_dynamic_targets) \
RW(GrowableObjectArray, token_objects) \
RW(Array, token_objects_map) \
RW(GrowableObjectArray, megamorphic_cache_table) \
R_(Code, megamorphic_miss_code) \
R_(Function, megamorphic_miss_function) \

View file

@ -166,61 +166,6 @@ ISOLATE_UNIT_TEST_CASE(TypeArguments) {
EXPECT_EQ(type_arguments1.raw(), type_arguments3.raw());
}
ISOLATE_UNIT_TEST_CASE(TokenStream) {
Zone* zone = Thread::Current()->zone();
String& source = String::Handle(zone, String::New("= ( 9 , ."));
String& private_key = String::Handle(zone, String::New(""));
const TokenStream& token_stream =
TokenStream::Handle(zone, TokenStream::New(source, private_key, false));
TokenStream::Iterator iterator(zone, token_stream, TokenPosition::kMinSource);
iterator.Advance(); // Advance to '(' token.
EXPECT_EQ(Token::kLPAREN, iterator.CurrentTokenKind());
iterator.Advance();
iterator.Advance();
iterator.Advance(); // Advance to '.' token.
EXPECT_EQ(Token::kPERIOD, iterator.CurrentTokenKind());
iterator.Advance(); // Advance to end of stream.
EXPECT_EQ(Token::kEOS, iterator.CurrentTokenKind());
}
ISOLATE_UNIT_TEST_CASE(GenerateExactSource) {
// Verify the exact formatting of generated sources.
const char* kScriptChars =
"\n"
"class A {\n"
" static bar() { return 42; }\n"
" static fly() { return 5; }\n"
" void catcher(x) {\n"
" try {\n"
" if (x is! List) {\n"
" for (int i = 0; i < x; i++) {\n"
" fly();\n"
" ++i;\n"
" }\n"
" } else {\n"
" for (int i = 0; i < x; i--) {\n"
" !fly();\n"
" --i;\n"
" }\n"
" }\n"
" } on Blah catch (a) {\n"
" _print(17);\n"
" } catch (e, s) {\n"
" bar()\n"
" }\n"
" }\n"
"}\n";
String& url = String::Handle(String::New("dart-test:GenerateExactSource"));
String& source = String::Handle(String::New(kScriptChars));
Script& script =
Script::Handle(Script::New(url, source, RawScript::kScriptTag));
script.Tokenize(String::Handle(String::New("")));
const TokenStream& tokens = TokenStream::Handle(script.tokens());
const String& gen_source = String::Handle(tokens.GenerateSource());
EXPECT_STREQ(source.ToCString(), gen_source.ToCString());
}
TEST_CASE(Class_ComputeEndTokenPos) {
const char* kScript =
"\n"
@ -2303,107 +2248,6 @@ ISOLATE_UNIT_TEST_CASE(Script) {
EXPECT_VALID(result);
}
ISOLATE_UNIT_TEST_CASE(EmbeddedScript) {
const char* url_chars = "builtin:test-case";
const char* text =
/* 1 */
"<!DOCTYPE html>\n"
/* 2 */
" ... more junk ...\n"
/* 3 */
" <script type='application/dart'>main() {\n"
/* 4 */
" return 'foo';\n"
/* 5 */
" }\n"
/* 6 */ "</script>\n";
const char* line1 = text;
const char* line2 = strstr(line1, "\n") + 1;
const char* line3 = strstr(line2, "\n") + 1;
const char* line4 = strstr(line3, "\n") + 1;
const char* line5 = strstr(line4, "\n") + 1;
const int first_dart_line = 3;
EXPECT(strstr(line3, "main") != NULL);
const int last_dart_line = 5;
EXPECT(strstr(line5, "}") != NULL);
const char* script_begin = strstr(text, "main");
EXPECT(script_begin != NULL);
const char* script_end = strstr(text, "</script>");
EXPECT(script_end != NULL);
int script_length = script_end - script_begin;
EXPECT(script_length > 0);
// The Dart script starts on line 3 instead of 1, offset is 3 - 1 = 2.
int line_offset = 2;
// Dart script starts with "main" on line 3.
intptr_t col_offset = script_begin - line3;
EXPECT(col_offset > 0);
char* src_chars = strdup(script_begin);
src_chars[script_length] = '\0';
const String& url = String::Handle(String::New(url_chars));
const String& source = String::Handle(String::New(src_chars));
const Script& script =
Script::Handle(Script::New(url, source, RawScript::kScriptTag));
script.SetLocationOffset(line_offset, col_offset);
String& str = String::Handle();
str = script.GetLine(first_dart_line);
EXPECT_STREQ("main() {", str.ToCString());
str = script.GetLine(last_dart_line);
EXPECT_STREQ(" }", str.ToCString());
script.Tokenize(String::Handle(String::New("ABC")));
// Tokens: 0: kIDENT, 1: kLPAREN, 2: kRPAREN, 3: kLBRACE, 4: kNEWLINE,
// 5: kRETURN, 6: kSTRING, 7: kSEMICOLON, 8: kNEWLINE,
// 9: kRBRACE, 10: kNEWLINE
intptr_t line, col;
intptr_t fast_line;
script.GetTokenLocation(TokenPosition(0), &line, &col);
EXPECT_EQ(first_dart_line, line);
EXPECT_EQ(col, col_offset + 1);
// We allow asking for only the line number, which only scans the token stream
// instead of rescanning the script.
script.GetTokenLocation(TokenPosition(0), &fast_line, NULL);
EXPECT_EQ(line, fast_line);
script.GetTokenLocation(TokenPosition(5), &line, &col); // Token 'return'
EXPECT_EQ(4, line); // 'return' is in line 4.
EXPECT_EQ(5, col); // Four spaces before 'return'.
// We allow asking for only the line number, which only scans the token stream
// instead of rescanning the script.
script.GetTokenLocation(TokenPosition(5), &fast_line, NULL);
EXPECT_EQ(line, fast_line);
TokenPosition first_idx, last_idx;
script.TokenRangeAtLine(3, &first_idx, &last_idx);
EXPECT_EQ(0, first_idx.value()); // Token 'main' is first token.
EXPECT_EQ(3, last_idx.value()); // Token { is last token.
script.TokenRangeAtLine(4, &first_idx, &last_idx);
EXPECT_EQ(5, first_idx.value()); // Token 'return' is first token.
EXPECT_EQ(7, last_idx.value()); // Token ; is last token.
script.TokenRangeAtLine(5, &first_idx, &last_idx);
EXPECT_EQ(9, first_idx.value()); // Token } is first and only token.
EXPECT_EQ(9, last_idx.value());
script.TokenRangeAtLine(1, &first_idx, &last_idx);
EXPECT_EQ(0, first_idx.value());
EXPECT_EQ(3, last_idx.value());
script.TokenRangeAtLine(6, &first_idx, &last_idx);
EXPECT_EQ(-1, first_idx.value());
EXPECT_EQ(-1, last_idx.value());
script.TokenRangeAtLine(1000, &first_idx, &last_idx);
EXPECT_EQ(-1, first_idx.value());
EXPECT_EQ(-1, last_idx.value());
free(src_chars);
}
ISOLATE_UNIT_TEST_CASE(Context) {
const int kNumVariables = 5;
const Context& parent_context = Context::Handle(Context::New(0));
@ -4041,7 +3885,7 @@ class ObjectAccumulator : public ObjectVisitor {
}
Object& handle = Object::Handle(obj);
// Skip some common simple objects to run in reasonable time.
if (handle.IsString() || handle.IsArray() || handle.IsLiteralToken()) {
if (handle.IsString() || handle.IsArray()) {
return;
}
objects_->Add(&handle);
@ -4323,18 +4167,6 @@ ISOLATE_UNIT_TEST_CASE(PrintJSONPrimitives) {
"\"valueAsString\":\"<being initialized>\"}",
js.ToCString());
}
// LiteralToken reference. This is meant to be an example of a
// "weird" type that isn't usually returned by the VM Service except
// when we are doing direct heap inspection.
{
JSONStream js;
LiteralToken& tok = LiteralToken::Handle(LiteralToken::New());
tok.PrintJSON(&js, true);
ElideJSONSubstring("objects", js.ToCString(), buffer);
EXPECT_STREQ(
"{\"type\":\"@Object\",\"_vmType\":\"LiteralToken\",\"id\":\"\"}",
buffer);
}
}
#endif // !PRODUCT

View file

@ -15,7 +15,6 @@
#include "vm/compiler/backend/il_printer.h"
#include "vm/compiler/frontend/scope_builder.h"
#include "vm/compiler/jit/compiler.h"
#include "vm/compiler_stats.h"
#include "vm/dart_api_impl.h"
#include "vm/dart_entry.h"
#include "vm/growable_array.h"
@ -38,7 +37,6 @@
#include "vm/symbols.h"
#include "vm/tags.h"
#include "vm/timeline.h"
#include "vm/timer.h"
#include "vm/zone.h"
namespace dart {

View file

@ -13,7 +13,6 @@
#include "vm/allocation.h"
#include "vm/ast.h"
#include "vm/class_finalizer.h"
#include "vm/compiler_stats.h"
#include "vm/hash_table.h"
#include "vm/kernel.h"
#include "vm/object.h"

View file

@ -2643,14 +2643,7 @@ const char* ProfileTrieWalker::CurrentToken() {
script.GetTokenLocation(token_pos, &line, &column, &token_len);
str = script.GetSnippet(line, column, line, column + token_len);
} else {
const TokenStream& token_stream =
TokenStream::Handle(zone, script.tokens());
if (token_stream.IsNull()) {
// No token position.
return NULL;
}
TokenStream::Iterator iterator(zone, token_stream, token_pos);
str = iterator.CurrentLiteral();
UNREACHABLE();
}
return str.IsNull() ? NULL : str.ToCString();
}

View file

@ -381,8 +381,6 @@ REGULAR_VISITOR(ClosureData)
REGULAR_VISITOR(SignatureData)
REGULAR_VISITOR(RedirectionData)
REGULAR_VISITOR(Field)
REGULAR_VISITOR(LiteralToken)
REGULAR_VISITOR(TokenStream)
REGULAR_VISITOR(Script)
REGULAR_VISITOR(Library)
REGULAR_VISITOR(LibraryPrefix)

View file

@ -29,8 +29,6 @@ typedef RawObject* RawCompressed;
V(SignatureData) \
V(RedirectionData) \
V(Field) \
V(LiteralToken) \
V(TokenStream) \
V(Script) \
V(Library) \
V(Namespace) \
@ -1158,30 +1156,6 @@ class RawField : public RawObject {
friend class CidRewriteVisitor;
};
class RawLiteralToken : public RawObject {
RAW_HEAP_OBJECT_IMPLEMENTATION(LiteralToken);
VISIT_FROM(RawObject*, literal_);
RawString* literal_; // Literal characters as they appear in source text.
RawObject* value_; // The actual object corresponding to the token.
VISIT_TO(RawObject*, value_);
Token::Kind kind_; // The literal kind (string, integer, double).
friend class SnapshotReader;
};
class RawTokenStream : public RawObject {
RAW_HEAP_OBJECT_IMPLEMENTATION(TokenStream);
VISIT_FROM(RawObject*, private_key_);
RawString* private_key_; // Key used for private identifiers.
RawGrowableObjectArray* token_objects_;
RawExternalTypedData* stream_;
VISIT_TO(RawObject*, stream_);
friend class SnapshotReader;
};
class RawScript : public RawObject {
public:
enum Kind {
@ -1204,7 +1178,6 @@ class RawScript : public RawObject {
RawArray* debug_positions_;
RawArray* yield_positions_;
RawKernelProgramInfo* kernel_program_info_;
RawTokenStream* tokens_;
RawString* source_;
VISIT_TO(RawObject*, source_);
RawObject** to_snapshot(Snapshot::Kind kind) {
@ -1213,7 +1186,7 @@ class RawScript : public RawObject {
return reinterpret_cast<RawObject**>(&ptr()->url_);
case Snapshot::kFull:
case Snapshot::kFullJIT:
return reinterpret_cast<RawObject**>(&ptr()->tokens_);
return reinterpret_cast<RawObject**>(&ptr()->kernel_program_info_);
case Snapshot::kMessage:
case Snapshot::kNone:
case Snapshot::kInvalid:
@ -2324,9 +2297,6 @@ class RawExternalTypedData : public RawInstance {
VISIT_TO(RawCompressed, length_)
uint8_t* data_;
friend class TokenStream;
friend class RawTokenStream;
};
// VM implementations of the basic types in the isolate.

View file

@ -591,38 +591,6 @@ void RawField::WriteTo(SnapshotWriter* writer,
UNREACHABLE();
}
RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
intptr_t tags,
Snapshot::Kind kind,
bool as_reference) {
UNREACHABLE();
return LiteralToken::null();
}
void RawLiteralToken::WriteTo(SnapshotWriter* writer,
intptr_t object_id,
Snapshot::Kind kind,
bool as_reference) {
UNREACHABLE();
}
RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
intptr_t tags,
Snapshot::Kind kind,
bool as_reference) {
UNREACHABLE();
return TokenStream::null();
}
void RawTokenStream::WriteTo(SnapshotWriter* writer,
intptr_t object_id,
Snapshot::Kind kind,
bool as_reference) {
UNREACHABLE();
}
RawScript* Script::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
intptr_t tags,

View file

@ -341,62 +341,6 @@ ISOLATE_UNIT_TEST_CASE(Service_Code) {
EXPECT_SUBSTRING("\"error\"", handler.msg());
}
ISOLATE_UNIT_TEST_CASE(Service_TokenStream) {
const char* kScript =
"var port;\n" // Set to our mock port by C++.
"\n"
"main() {\n"
"}";
Isolate* isolate = thread->isolate();
isolate->set_is_runnable(true);
Dart_Handle lib;
Library& vmlib = Library::Handle();
{
TransitionVMToNative transition(thread);
lib = TestCase::LoadTestScript(kScript, NULL);
EXPECT_VALID(lib);
vmlib ^= Api::UnwrapHandle(lib);
EXPECT(!vmlib.IsNull());
}
const String& script_name = String::Handle(String::New("test-lib"));
EXPECT(!script_name.IsNull());
const Script& script = Script::Handle(vmlib.LookupScript(script_name));
EXPECT(!script.IsNull());
const TokenStream& token_stream = TokenStream::Handle(script.tokens());
EXPECT(!token_stream.IsNull());
ObjectIdRing* ring = isolate->object_id_ring();
intptr_t id = ring->GetIdForObject(token_stream.raw());
// Build a mock message handler and wrap it in a dart port.
ServiceTestMessageHandler handler;
Dart_Port port_id = PortMap::CreatePort(&handler);
Dart_Handle port = Api::NewHandle(thread, SendPort::New(port_id));
EXPECT_VALID(port);
{
TransitionVMToNative transition(thread);
EXPECT_VALID(Dart_SetField(lib, NewString("port"), port));
}
Array& service_msg = Array::Handle();
// Fetch object.
service_msg = EvalF(lib,
"[0, port, '0', 'getObject', "
"['objectId'], ['objects/%" Pd "']]",
id);
HandleIsolateMessage(isolate, service_msg);
EXPECT_EQ(MessageHandler::kOK, handler.HandleNextMessage());
// Check type.
EXPECT_SUBSTRING("\"type\":\"Object\"", handler.msg());
EXPECT_SUBSTRING("\"_vmType\":\"TokenStream\"", handler.msg());
// Check for members array.
EXPECT_SUBSTRING("\"members\":[", handler.msg());
}
ISOLATE_UNIT_TEST_CASE(Service_PcDescriptors) {
const char* kScript =
"var port;\n" // Set to our mock port by C++.

View file

@ -219,7 +219,6 @@ SnapshotReader::SnapshotReader(const uint8_t* buffer,
type_(AbstractType::Handle(zone_)),
type_arguments_(TypeArguments::Handle(zone_)),
tokens_(GrowableObjectArray::Handle(zone_)),
stream_(TokenStream::Handle(zone_)),
data_(ExternalTypedData::Handle(zone_)),
typed_data_(TypedData::Handle(zone_)),
function_(Function::Handle(zone_)),

View file

@ -63,7 +63,6 @@ class RawLanguageError;
class RawLibrary;
class RawLibraryPrefix;
class RawLinkedHashMap;
class RawLiteralToken;
class RawLocalVarDescriptors;
class RawMegamorphicCache;
class RawMint;
@ -84,7 +83,6 @@ class RawSmi;
class RawStackMap;
class RawStackTrace;
class RawSubtypeTestCache;
class RawTokenStream;
class RawTwoByteString;
class RawType;
class RawTypeArguments;
@ -95,7 +93,6 @@ class RawUnhandledException;
class RawUnresolvedClass;
class RawWeakProperty;
class String;
class TokenStream;
class TypeArguments;
class TypedData;
class UnhandledException;
@ -331,7 +328,6 @@ class SnapshotReader : public BaseReader {
AbstractType* TypeHandle() { return &type_; }
TypeArguments* TypeArgumentsHandle() { return &type_arguments_; }
GrowableObjectArray* TokensHandle() { return &tokens_; }
TokenStream* StreamHandle() { return &stream_; }
ExternalTypedData* DataHandle() { return &data_; }
TypedData* TypedDataHandle() { return &typed_data_; }
Function* FunctionHandle() { return &function_; }
@ -441,7 +437,6 @@ class SnapshotReader : public BaseReader {
AbstractType& type_; // Temporary type handle.
TypeArguments& type_arguments_; // Temporary type argument handle.
GrowableObjectArray& tokens_; // Temporary tokens handle.
TokenStream& stream_; // Temporary token stream handle.
ExternalTypedData& data_; // Temporary stream data handle.
TypedData& typed_data_; // Temporary typed data handle.
Function& function_; // Temporary function handle.
@ -470,7 +465,6 @@ class SnapshotReader : public BaseReader {
friend class Library;
friend class LibraryPrefix;
friend class LinkedHashMap;
friend class LiteralToken;
friend class MirrorReference;
friend class MixinAppType;
friend class Namespace;
@ -480,7 +474,6 @@ class SnapshotReader : public BaseReader {
friend class Script;
friend class SignatureData;
friend class SubtypeTestCache;
friend class TokenStream;
friend class Type;
friend class TypeArguments;
friend class TypeParameter;
@ -746,7 +739,6 @@ class SnapshotWriter : public BaseWriter {
friend class RawInstructions;
friend class RawLibrary;
friend class RawLinkedHashMap;
friend class RawLiteralToken;
friend class RawLocalVarDescriptors;
friend class RawMirrorReference;
friend class RawObjectPool;
@ -755,7 +747,6 @@ class SnapshotWriter : public BaseWriter {
friend class RawScript;
friend class RawStackTrace;
friend class RawSubtypeTestCache;
friend class RawTokenStream;
friend class RawType;
friend class RawTypeRef;
friend class RawBoundedType;

View file

@ -16,6 +16,7 @@
#include "vm/malloc_hooks.h"
#include "vm/snapshot.h"
#include "vm/symbols.h"
#include "vm/timer.h"
#include "vm/unicode.h"
#include "vm/unit_test.h"
@ -399,7 +400,6 @@ ISOLATE_UNIT_TEST_CASE(SerializeSingletons) {
TEST_ROUND_TRIP_IDENTICAL(Object::type_arguments_class());
TEST_ROUND_TRIP_IDENTICAL(Object::function_class());
TEST_ROUND_TRIP_IDENTICAL(Object::field_class());
TEST_ROUND_TRIP_IDENTICAL(Object::token_stream_class());
TEST_ROUND_TRIP_IDENTICAL(Object::script_class());
TEST_ROUND_TRIP_IDENTICAL(Object::library_class());
TEST_ROUND_TRIP_IDENTICAL(Object::code_class());
@ -726,78 +726,6 @@ ISOLATE_UNIT_TEST_CASE(SerializeEmptyByteArray) {
delete message;
}
static void GenerateSourceAndCheck(const Script& script) {
// Check if we are able to generate the source from the token stream.
// Rescan this source and compare the token stream to see if they are
// the same.
Zone* zone = Thread::Current()->zone();
const TokenStream& expected_tokens =
TokenStream::Handle(zone, script.tokens());
TokenStream::Iterator expected_iterator(zone, expected_tokens,
TokenPosition::kMinSource,
TokenStream::Iterator::kAllTokens);
const String& str = String::Handle(zone, expected_tokens.GenerateSource());
const String& private_key =
String::Handle(zone, expected_tokens.PrivateKey());
const TokenStream& reconstructed_tokens =
TokenStream::Handle(zone, TokenStream::New(str, private_key, false));
expected_iterator.SetCurrentPosition(TokenPosition::kMinSource);
TokenStream::Iterator reconstructed_iterator(
zone, reconstructed_tokens, TokenPosition::kMinSource,
TokenStream::Iterator::kAllTokens);
Token::Kind expected_kind = expected_iterator.CurrentTokenKind();
Token::Kind reconstructed_kind = reconstructed_iterator.CurrentTokenKind();
String& expected_literal = String::Handle(zone);
String& actual_literal = String::Handle(zone);
while (expected_kind != Token::kEOS && reconstructed_kind != Token::kEOS) {
EXPECT_EQ(expected_kind, reconstructed_kind);
expected_literal ^= expected_iterator.CurrentLiteral();
actual_literal ^= reconstructed_iterator.CurrentLiteral();
EXPECT_STREQ(expected_literal.ToCString(), actual_literal.ToCString());
expected_iterator.Advance();
reconstructed_iterator.Advance();
expected_kind = expected_iterator.CurrentTokenKind();
reconstructed_kind = reconstructed_iterator.CurrentTokenKind();
}
}
static void IterateScripts(const Library& lib) {
const Array& lib_scripts = Array::Handle(lib.LoadedScripts());
Script& script = Script::Handle();
String& uri = String::Handle();
for (intptr_t i = 0; i < lib_scripts.Length(); i++) {
script ^= lib_scripts.At(i);
EXPECT(!script.IsNull());
uri = script.url();
OS::PrintErr("Generating source for part: %s\n", uri.ToCString());
GenerateSourceAndCheck(script);
}
}
ISOLATE_UNIT_TEST_CASE(GenerateSource) {
// Disable stack trace collection for this test as it results in a timeout.
bool stack_trace_collection_enabled =
MallocHooks::stack_trace_collection_enabled();
MallocHooks::set_stack_trace_collection_enabled(false);
Zone* zone = thread->zone();
Isolate* isolate = thread->isolate();
const GrowableObjectArray& libs =
GrowableObjectArray::Handle(zone, isolate->object_store()->libraries());
Library& lib = Library::Handle();
String& uri = String::Handle();
for (intptr_t i = 0; i < libs.Length(); i++) {
lib ^= libs.At(i);
EXPECT(!lib.IsNull());
uri = lib.url();
OS::PrintErr("Generating source for library: %s\n", uri.ToCString());
IterateScripts(lib);
}
MallocHooks::set_stack_trace_collection_enabled(
stack_trace_collection_enabled);
}
VM_UNIT_TEST_CASE(FullSnapshot) {
const char* kScriptChars =
"class Fields {\n"

View file

@ -184,8 +184,6 @@ class ObjectPointerVisitor;
V(SignatureData, "SignatureData") \
V(RedirectionData, "RedirectionData") \
V(Field, "Field") \
V(LiteralToken, "LiteralToken") \
V(TokenStream, "TokenStream") \
V(Script, "Script") \
V(LibraryClass, "Library") \
V(LibraryPrefix, "LibraryPrefix") \

View file

@ -4,7 +4,6 @@
#include "vm/thread.h"
#include "vm/compiler_stats.h"
#include "vm/dart_api_state.h"
#include "vm/growable_array.h"
#include "vm/isolate.h"
@ -34,10 +33,6 @@ Thread::~Thread() {
ASSERT(isolate_ == NULL);
ASSERT(store_buffer_block_ == NULL);
ASSERT(marking_stack_block_ == NULL);
if (compiler_stats_ != NULL) {
delete compiler_stats_;
compiler_stats_ = NULL;
}
// There should be no top api scopes at this point.
ASSERT(api_top_scope() == NULL);
// Delete the resusable api scope if there is one.
@ -104,7 +99,6 @@ Thread::Thread(Isolate* isolate)
active_stacktrace_(Object::null()),
resume_pc_(0),
sticky_error_(Error::null()),
compiler_stats_(NULL),
REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS)
REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) safepoint_state_(0),
execution_state_(kThreadInNative),
@ -142,12 +136,6 @@ Thread::Thread(Isolate* isolate)
InitVMConstants();
}
if (FLAG_support_compiler_stats) {
compiler_stats_ = new CompilerStats(isolate);
if (FLAG_compiler_benchmark) {
compiler_stats_->EnableBenchmark();
}
}
// This thread should not yet own any zones. If it does, we need to make sure
// we've accounted for any memory it has already allocated.
if (zone_ == NULL) {

View file

@ -25,7 +25,6 @@ class Array;
class CompilerState;
class Class;
class Code;
class CompilerStats;
class Error;
class ExceptionHandlers;
class Field;
@ -617,8 +616,6 @@ class Thread : public BaseThread {
return OFFSET_OF(Thread, async_stack_trace_);
}
CompilerStats* compiler_stats() { return compiler_stats_; }
#if defined(DEBUG)
#define REUSABLE_HANDLE_SCOPE_ACCESSORS(object) \
void set_reusable_##object##_handle_scope_active(bool value) { \
@ -887,8 +884,6 @@ class Thread : public BaseThread {
RawError* sticky_error_;
CompilerStats* compiler_stats_;
// Reusable handles support.
#define REUSABLE_HANDLE_FIELDS(object) object* object##_handle_;
REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_FIELDS)

View file

@ -98,74 +98,6 @@ class Timer : public ValueObject {
DISALLOW_COPY_AND_ASSIGN(Timer);
};
// The class TimerScope is used to start and stop a timer within a scope.
// It is used as follows:
// {
// TimerScope timer(FLAG_name_of_flag, timer, isolate);
// .....
// code that needs to be timed.
// ....
// }
class TimerScope : public StackResource {
public:
TimerScope(bool flag, Timer* timer, Thread* thread = NULL)
: StackResource(thread), nested_(false), timer_(flag ? timer : NULL) {
Init();
}
void Init() {
if (timer_ != NULL) {
if (!timer_->running()) {
timer_->Start();
} else {
nested_ = true;
}
}
}
~TimerScope() {
if (timer_ != NULL) {
if (!nested_) {
timer_->Stop();
}
}
}
private:
bool nested_;
Timer* const timer_;
DISALLOW_ALLOCATION();
DISALLOW_COPY_AND_ASSIGN(TimerScope);
};
class PauseTimerScope : public StackResource {
public:
PauseTimerScope(bool flag, Timer* timer, Thread* thread = NULL)
: StackResource(thread), nested_(false), timer_(flag ? timer : NULL) {
if (timer_) {
if (timer_->running()) {
timer_->Stop();
} else {
nested_ = true;
}
}
}
~PauseTimerScope() {
if (timer_) {
if (!nested_) {
timer_->Start();
}
}
}
private:
bool nested_;
Timer* const timer_;
DISALLOW_ALLOCATION();
DISALLOW_COPY_AND_ASSIGN(PauseTimerScope);
};
} // namespace dart
#endif // RUNTIME_VM_TIMER_H_

View file

@ -779,7 +779,6 @@ void AssemblerTest::Assemble() {
const Script& script = Script::Handle(
Script::New(function_name, String::Handle(String::New(kDummyScript)),
RawScript::kSourceTag));
script.Tokenize(String::Handle());
const Library& lib = Library::Handle(Library::CoreLibrary());
const Class& cls = Class::ZoneHandle(
Class::New(lib, function_name, script, TokenPosition::kMinSource));

View file

@ -40,8 +40,6 @@ vm_sources = [
"code_patcher_x64.cc",
"compilation_trace.cc",
"compilation_trace.h",
"compiler_stats.cc",
"compiler_stats.h",
"constants_arm.h",
"constants_arm64.h",
"constants_dbc.h",

View file

@ -159,7 +159,6 @@ mirrors/constructor_private_name_test: RuntimeError # Issue 33345 - Incorrect qu
mirrors/constructors_test: CompileTimeError # Issue 31402 (Invocation arguments)
mirrors/dart2js_mirrors_test: RuntimeError # 31916
mirrors/deferred_type_test: CompileTimeError, RuntimeError
mirrors/empty_test: Crash, RuntimeError
mirrors/enum_test: RuntimeError # Issue 31402 (Invocation arguments)
mirrors/equality_test: RuntimeError
mirrors/fake_function_without_call_test: RuntimeError, OK