mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
- Use conditional code inclusion for the dart_no_snapshot and dart executables using the MACRO DART_NO_SNAPSHOT
- Do some minor modifications to the intrinsifier code to not do redundant fingerprint checks and avoid code duplication. These changes result in a text segment size savings of about 110k. Old Sizes: text data bss dec hex filename 3801418 7696 19261 3828375 3a6a97 (TOTALS) New sizes: text data bss dec hex filename 3690342 7696 19261 3717299 38b8b3 (TOTALS) Review URL: https://codereview.chromium.org//1134623004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45704 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
f469f59b60
commit
8f9eee3f22
12 changed files with 128 additions and 41 deletions
|
@ -349,12 +349,12 @@
|
|||
},
|
||||
},
|
||||
{
|
||||
'target_name': 'libdart_withcore',
|
||||
'target_name': 'libdart_nosnapshot',
|
||||
'type': 'static_library',
|
||||
'toolsets':['target','host'],
|
||||
'dependencies': [
|
||||
'libdart_lib_withcore',
|
||||
'libdart_vm',
|
||||
'libdart_lib_nosnapshot',
|
||||
'libdart_vm_nosnapshot',
|
||||
'libdouble_conversion',
|
||||
'generate_version_cc_file#host',
|
||||
],
|
||||
|
@ -382,7 +382,7 @@
|
|||
'type': 'executable',
|
||||
'toolsets':['host'],
|
||||
'dependencies': [
|
||||
'libdart_withcore',
|
||||
'libdart_nosnapshot',
|
||||
'libdart_builtin',
|
||||
],
|
||||
'include_dirs': [
|
||||
|
@ -609,7 +609,7 @@
|
|||
'type': 'executable',
|
||||
'toolsets':['host'],
|
||||
'dependencies': [
|
||||
'libdart_withcore',
|
||||
'libdart_nosnapshot',
|
||||
'libdart_builtin',
|
||||
'libdart_io',
|
||||
'generate_bootstrap_resources_cc_file#host',
|
||||
|
@ -662,7 +662,7 @@
|
|||
'target_name': 'dart_no_snapshot',
|
||||
'type': 'executable',
|
||||
'dependencies': [
|
||||
'libdart_withcore',
|
||||
'libdart_nosnapshot',
|
||||
'libdart_builtin',
|
||||
'libdart_io',
|
||||
'generate_resources_cc_file#host',
|
||||
|
@ -721,7 +721,7 @@
|
|||
'target_name': 'run_vm_tests',
|
||||
'type': 'executable',
|
||||
'dependencies': [
|
||||
'libdart_withcore',
|
||||
'libdart',
|
||||
'libdart_builtin',
|
||||
'libdart_io',
|
||||
'generate_snapshot_file#host',
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
'version_in_cc_file': 'vm/version_in.cc',
|
||||
'version_cc_file': '<(gen_source_dir)/version.cc',
|
||||
|
||||
'libdart_deps': ['libdart_lib_withcore', 'libdart_lib', 'libdart_vm',
|
||||
'libdart_deps': ['libdart_lib_nosnapshot', 'libdart_lib',
|
||||
'libdart_vm_nosnapshot', 'libdart_vm',
|
||||
'libdouble_conversion',],
|
||||
},
|
||||
'targets': [
|
||||
|
@ -93,7 +94,7 @@
|
|||
'type': 'executable',
|
||||
'toolsets':['target'],
|
||||
# The dependencies here are the union of the dependencies of libdart and
|
||||
# libdart_withcore.
|
||||
# libdart_nosnapshot.
|
||||
'dependencies': ['<@(libdart_deps)'],
|
||||
'sources': [
|
||||
'vm/libdart_dependency_helper.cc',
|
||||
|
@ -104,7 +105,7 @@
|
|||
'type': 'executable',
|
||||
'toolsets':['host'],
|
||||
# The dependencies here are the union of the dependencies of libdart and
|
||||
# libdart_withcore.
|
||||
# libdart_nosnapshot.
|
||||
'dependencies': ['<@(libdart_deps)'],
|
||||
'sources': [
|
||||
'vm/libdart_dependency_helper.cc',
|
||||
|
|
|
@ -183,6 +183,7 @@ void ClassFinalizer::CollectInterfaces(const Class& cls,
|
|||
}
|
||||
|
||||
|
||||
#if defined(DART_NO_SNAPSHOT)
|
||||
void ClassFinalizer::VerifyBootstrapClasses() {
|
||||
if (FLAG_trace_class_finalization) {
|
||||
OS::Print("VerifyBootstrapClasses START.\n");
|
||||
|
@ -246,6 +247,7 @@ void ClassFinalizer::VerifyBootstrapClasses() {
|
|||
}
|
||||
Isolate::Current()->heap()->Verify();
|
||||
}
|
||||
#endif // defined(DART_NO_SNAPSHOT).
|
||||
|
||||
|
||||
// Resolve unresolved_class in the library of cls, or return null.
|
||||
|
|
|
@ -93,9 +93,11 @@ class ClassFinalizer : public AllStatic {
|
|||
// Finalize the class including its fields and functions.
|
||||
static void FinalizeClass(const Class& cls);
|
||||
|
||||
#if defined(DART_NO_SNAPSHOT)
|
||||
// Verify that the classes have been properly prefinalized. This is
|
||||
// needed during bootstrapping where the classes have been preloaded.
|
||||
static void VerifyBootstrapClasses();
|
||||
#endif // defined(DART_NO_SNAPSHOT).
|
||||
|
||||
// Resolve the class of the type, but not the type's type arguments.
|
||||
static void ResolveTypeClass(const Class& cls, const AbstractType& type);
|
||||
|
|
|
@ -224,15 +224,12 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_buffer, void* data) {
|
|||
// Setup for profiling.
|
||||
Profiler::InitProfilingForIsolate(isolate);
|
||||
|
||||
if (snapshot_buffer == NULL) {
|
||||
const Error& error = Error::Handle(Object::Init(isolate));
|
||||
if (!error.IsNull()) {
|
||||
return error.raw();
|
||||
}
|
||||
} else {
|
||||
// Initialize from snapshot (this should replicate the functionality
|
||||
// of Object::Init(..) in a regular isolate creation path.
|
||||
Object::InitFromSnapshot(isolate);
|
||||
const Error& error = Error::Handle(Object::Init(isolate));
|
||||
if (!error.IsNull()) {
|
||||
return error.raw();
|
||||
}
|
||||
if (snapshot_buffer != NULL) {
|
||||
// Read the snapshot and setup the initial state.
|
||||
|
||||
// TODO(turnidge): Remove once length is not part of the snapshot.
|
||||
const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_buffer);
|
||||
|
|
|
@ -34,6 +34,7 @@ bool Intrinsifier::CanIntrinsify(const Function& function) {
|
|||
}
|
||||
|
||||
|
||||
#if defined(DART_NO_SNAPSHOT)
|
||||
void Intrinsifier::InitializeState() {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
Library& lib = Library::Handle(isolate);
|
||||
|
@ -90,6 +91,7 @@ void Intrinsifier::InitializeState() {
|
|||
|
||||
#undef SETUP_FUNCTION
|
||||
}
|
||||
#endif // defined(DART_NO_SNAPSHOT).
|
||||
|
||||
|
||||
static void EmitCodeFor(FlowGraphCompiler* compiler,
|
||||
|
@ -143,7 +145,6 @@ bool Intrinsifier::GraphIntrinsify(const ParsedFunction& parsed_function,
|
|||
switch (function.recognized_kind()) {
|
||||
#define EMIT_CASE(class_name, function_name, enum_name, fp) \
|
||||
case MethodRecognizer::k##enum_name: \
|
||||
CHECK_FINGERPRINT3(function, class_name, function_name, enum_name, fp); \
|
||||
if (!Build_##enum_name(graph)) return false; \
|
||||
break;
|
||||
|
||||
|
@ -187,23 +188,21 @@ void Intrinsifier::Intrinsify(const ParsedFunction& parsed_function,
|
|||
|
||||
#define EMIT_CASE(class_name, function_name, enum_name, fp) \
|
||||
case MethodRecognizer::k##enum_name: \
|
||||
CHECK_FINGERPRINT3(function, class_name, function_name, enum_name, fp); \
|
||||
compiler->assembler()->Comment("Intrinsic"); \
|
||||
enum_name(compiler->assembler()); \
|
||||
break;
|
||||
|
||||
if (FLAG_throw_on_javascript_int_overflow && (Smi::kBits >= 32)) {
|
||||
// Integer intrinsics are in the core library, but we don't want to
|
||||
// intrinsify when Smi > 32 bits if we are looking for javascript integer
|
||||
// overflow.
|
||||
switch (function.recognized_kind()) {
|
||||
ALL_INTRINSICS_NO_INTEGER_LIB_LIST(EMIT_CASE);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// Integer intrinsics are in the core library, but we don't want to
|
||||
// intrinsify when Smi > 32 bits if we are looking for javascript integer
|
||||
// overflow.
|
||||
if (!(FLAG_throw_on_javascript_int_overflow && (Smi::kBits >= 32))) {
|
||||
switch (function.recognized_kind()) {
|
||||
ALL_INTRINSICS_NO_INTEGER_LIB_LIST(EMIT_CASE);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (function.recognized_kind()) {
|
||||
ALL_INTRINSICS_LIST(EMIT_CASE);
|
||||
CORE_INTEGER_LIB_INTRINSIC_LIST(EMIT_CASE)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@ class Intrinsifier : public AllStatic {
|
|||
public:
|
||||
static void Intrinsify(const ParsedFunction& parsed_function,
|
||||
FlowGraphCompiler* compiler);
|
||||
#if defined(DART_NO_SNAPSHOT)
|
||||
static void InitializeState();
|
||||
#endif
|
||||
|
||||
static bool GraphIntrinsify(const ParsedFunction& parsed_function,
|
||||
FlowGraphCompiler* compiler);
|
||||
|
|
|
@ -25,15 +25,21 @@ bool MethodRecognizer::PolymorphicTarget(const Function& function) {
|
|||
}
|
||||
|
||||
|
||||
const char* MethodRecognizer::KindToCString(Kind kind) {
|
||||
#define KIND_TO_STRING(class_name, function_name, enum_name, fp) \
|
||||
if (kind == k##enum_name) return #enum_name;
|
||||
#enum_name,
|
||||
static const char* recognized_list_method_name[] = {
|
||||
RECOGNIZED_LIST(KIND_TO_STRING)
|
||||
};
|
||||
#undef KIND_TO_STRING
|
||||
|
||||
const char* MethodRecognizer::KindToCString(Kind kind) {
|
||||
if (kind > kUnknown && kind < kNumRecognizedMethods)
|
||||
return recognized_list_method_name[kind];
|
||||
return "?";
|
||||
}
|
||||
|
||||
|
||||
#if defined(DART_NO_SNAPSHOT)
|
||||
void MethodRecognizer::InitializeState() {
|
||||
GrowableArray<Library*> libs(3);
|
||||
libs.Add(&Library::ZoneHandle(Library::CoreLibrary()));
|
||||
|
@ -83,5 +89,6 @@ void MethodRecognizer::InitializeState() {
|
|||
#undef SET_IS_POLYMORPHIC_TARGET
|
||||
#undef SET_FUNCTION_BIT
|
||||
}
|
||||
#endif // defined(DART_NO_SNAPSHOT).
|
||||
|
||||
} // namespace dart
|
||||
|
|
|
@ -455,7 +455,9 @@ RECOGNIZED_LIST(DEFINE_ENUM_LIST)
|
|||
static bool AlwaysInline(const Function& function);
|
||||
static bool PolymorphicTarget(const Function& function);
|
||||
static const char* KindToCString(Kind kind);
|
||||
#if defined(DART_NO_SNAPSHOT)
|
||||
static void InitializeState();
|
||||
#endif // defined(DART_NO_SNAPSHOT).
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -927,6 +927,10 @@ void Object::RegisterPrivateClass(const Class& cls,
|
|||
|
||||
RawError* Object::Init(Isolate* isolate) {
|
||||
TIMERSCOPE(isolate, time_bootstrap);
|
||||
|
||||
#if defined(DART_NO_SNAPSHOT)
|
||||
// Object::Init version when we are running in a version of dart that does
|
||||
// not have a full snapshot linked in.
|
||||
ObjectStore* object_store = isolate->object_store();
|
||||
|
||||
Class& cls = Class::Handle(isolate);
|
||||
|
@ -1426,11 +1430,10 @@ RawError* Object::Init(Isolate* isolate) {
|
|||
isolate->object_store()->InitKnownObjects();
|
||||
|
||||
return Error::null();
|
||||
}
|
||||
|
||||
|
||||
void Object::InitFromSnapshot(Isolate* isolate) {
|
||||
TIMERSCOPE(isolate, time_bootstrap);
|
||||
#else // defined(DART_NO_SNAPSHOT).
|
||||
// Object::Init version when we are running in a version of dart that has
|
||||
// a full snapshot linked in and an isolate is initialized using the full
|
||||
// snapshot.
|
||||
ObjectStore* object_store = isolate->object_store();
|
||||
|
||||
Class& cls = Class::Handle();
|
||||
|
@ -1540,6 +1543,9 @@ void Object::InitFromSnapshot(Isolate* isolate) {
|
|||
object_store->set_empty_context(context);
|
||||
|
||||
StubCode::InitBootstrapStubs(isolate);
|
||||
#endif // defined(DART_NO_SNAPSHOT).
|
||||
|
||||
return Error::null();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -525,7 +525,6 @@ class Object {
|
|||
|
||||
// Initialize a new isolate either from source or from a snapshot.
|
||||
static RawError* Init(Isolate* isolate);
|
||||
static void InitFromSnapshot(Isolate* isolate);
|
||||
|
||||
static void MakeUnusedSpaceTraversable(const Object& obj,
|
||||
intptr_t original_size,
|
||||
|
|
|
@ -103,7 +103,77 @@
|
|||
}]],
|
||||
},
|
||||
{
|
||||
'target_name': 'libdart_lib_withcore',
|
||||
'target_name': 'libdart_vm_nosnapshot',
|
||||
'type': 'static_library',
|
||||
'toolsets':['host', 'target'],
|
||||
'dependencies': [
|
||||
'generate_service_cc_file#host'
|
||||
],
|
||||
'includes': [
|
||||
'vm_sources.gypi',
|
||||
'../platform/platform_headers.gypi',
|
||||
'../platform/platform_sources.gypi',
|
||||
],
|
||||
'sources': [
|
||||
# Include generated source files.
|
||||
'<(service_cc_file)',
|
||||
],
|
||||
'sources/': [
|
||||
# Exclude all _test.[cc|h] files.
|
||||
['exclude', '_test\\.(cc|h)$'],
|
||||
],
|
||||
'include_dirs': [
|
||||
'..',
|
||||
],
|
||||
'defines': [
|
||||
'DART_NO_SNAPSHOT',
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="linux"', {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'-lpthread',
|
||||
'-lrt',
|
||||
'-ldl',
|
||||
],
|
||||
},
|
||||
}],
|
||||
['OS=="android" and _toolset=="host"', {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'-lpthread',
|
||||
'-lrt',
|
||||
'-ldl',
|
||||
],
|
||||
},
|
||||
}],
|
||||
['OS=="win"', {
|
||||
'sources/' : [
|
||||
['exclude', 'gdbjit.cc'],
|
||||
],
|
||||
}],
|
||||
['dart_vtune_support==0', {
|
||||
'sources/' : [
|
||||
['exclude', 'vtune\\.(cc|h)$'],
|
||||
],
|
||||
}],
|
||||
['dart_vtune_support==1', {
|
||||
'include_dirs': ['<(dart_vtune_root)/include'],
|
||||
'defines': ['DART_VTUNE_SUPPORT'],
|
||||
'link_settings': {
|
||||
'conditions': [
|
||||
['OS=="linux"', {
|
||||
'libraries': ['-ljitprofiling'],
|
||||
}],
|
||||
['OS=="win"', {
|
||||
'libraries': ['-ljitprofiling.lib'],
|
||||
}],
|
||||
],
|
||||
},
|
||||
}]],
|
||||
},
|
||||
{
|
||||
'target_name': 'libdart_lib_nosnapshot',
|
||||
'type': 'static_library',
|
||||
'toolsets':['host', 'target'],
|
||||
'dependencies': [
|
||||
|
|
Loading…
Reference in a new issue