17c33d8d52
This is a reland of 2852408881
Original change's description:
> [vm] Reduce size of Class objects in AOT and PRODUCT modes
>
> This change conditionally removes certain fields from Class objects
> in AOT and PRODUCT modes.
>
> Flutter gallery in release-sizeopt mode:
> Snapshot size -0.47% (arm64), -0.44% (arm)
> Heap size of snapshot objects -4.1% (arm64), -4.3% (arm)
>
> On a large Flutter application compiled in --dwarf-stack-traces mode:
> Heap size of Class objects -26%
> Heap size of all snapshot objects -3.6%
>
> TEST=ci
> Issue: https://github.com/dart-lang/sdk/issues/44020
> Change-Id: I795c625b71558cd2f336f92fc326c36fd339cd4b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195700
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
TEST=ci
Change-Id: Ib473a959a2c610b7a0e6f4000b2101e5256c6119
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196103
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
142 lines
3.4 KiB
C++
142 lines
3.4 KiB
C++
// Copyright (c) 2017, 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_COMPILATION_TRACE_H_
|
|
#define RUNTIME_VM_COMPILATION_TRACE_H_
|
|
|
|
#include "platform/assert.h"
|
|
#include "vm/object.h"
|
|
#include "vm/program_visitor.h"
|
|
#include "vm/zone_text_buffer.h"
|
|
|
|
#if !defined(DART_PRECOMPILED_RUNTIME)
|
|
|
|
namespace dart {
|
|
|
|
class CompilationTraceSaver : public FunctionVisitor {
|
|
public:
|
|
explicit CompilationTraceSaver(Zone* zone);
|
|
void VisitFunction(const Function& function);
|
|
|
|
void StealBuffer(uint8_t** buffer, intptr_t* buffer_length) {
|
|
*buffer = reinterpret_cast<uint8_t*>(buf_.buffer());
|
|
*buffer_length = buf_.length();
|
|
}
|
|
|
|
private:
|
|
ZoneTextBuffer buf_;
|
|
String& func_name_;
|
|
Class& cls_;
|
|
String& cls_name_;
|
|
Library& lib_;
|
|
String& uri_;
|
|
};
|
|
|
|
class CompilationTraceLoader : public ValueObject {
|
|
public:
|
|
explicit CompilationTraceLoader(Thread* thread);
|
|
|
|
ObjectPtr CompileTrace(uint8_t* buffer, intptr_t buffer_length);
|
|
|
|
private:
|
|
ObjectPtr CompileTriple(const char* uri_cstr,
|
|
const char* cls_cstr,
|
|
const char* func_cstr);
|
|
ObjectPtr CompileFunction(const Function& function);
|
|
void SpeculateInstanceCallTargets(const Function& function);
|
|
|
|
Thread* thread_;
|
|
Zone* zone_;
|
|
String& uri_;
|
|
String& class_name_;
|
|
String& function_name_;
|
|
String& function_name2_;
|
|
Library& lib_;
|
|
Class& cls_;
|
|
Function& function_;
|
|
Function& function2_;
|
|
Field& field_;
|
|
Array& sites_;
|
|
ICData& site_;
|
|
AbstractType& static_type_;
|
|
Class& receiver_cls_;
|
|
Function& target_;
|
|
String& selector_;
|
|
Array& args_desc_;
|
|
Object& error_;
|
|
};
|
|
|
|
class TypeFeedbackSaver : public FunctionVisitor {
|
|
public:
|
|
explicit TypeFeedbackSaver(BaseWriteStream* stream);
|
|
|
|
void WriteHeader();
|
|
void SaveClasses();
|
|
void SaveFields();
|
|
void VisitFunction(const Function& function);
|
|
|
|
private:
|
|
void WriteClassByName(const Class& cls);
|
|
void WriteString(const String& value);
|
|
void WriteInt(intptr_t value) { stream_->Write(static_cast<int32_t>(value)); }
|
|
|
|
BaseWriteStream* const stream_;
|
|
Class& cls_;
|
|
Library& lib_;
|
|
String& str_;
|
|
Array& fields_;
|
|
Field& field_;
|
|
Code& code_;
|
|
Array& call_sites_;
|
|
ICData& call_site_;
|
|
};
|
|
|
|
class TypeFeedbackLoader : public ValueObject {
|
|
public:
|
|
explicit TypeFeedbackLoader(Thread* thread);
|
|
~TypeFeedbackLoader();
|
|
|
|
ObjectPtr LoadFeedback(ReadStream* stream);
|
|
|
|
private:
|
|
ObjectPtr CheckHeader();
|
|
ObjectPtr LoadClasses();
|
|
ObjectPtr LoadFields();
|
|
ObjectPtr LoadFunction();
|
|
FunctionPtr FindFunction(UntaggedFunction::Kind kind,
|
|
const TokenPosition& token_pos);
|
|
|
|
ClassPtr ReadClassByName();
|
|
StringPtr ReadString();
|
|
intptr_t ReadInt() { return stream_->Read<int32_t>(); }
|
|
|
|
Thread* thread_;
|
|
Zone* zone_;
|
|
ReadStream* stream_;
|
|
intptr_t num_cids_;
|
|
intptr_t* cid_map_;
|
|
String& uri_;
|
|
Library& lib_;
|
|
String& cls_name_;
|
|
Class& cls_;
|
|
String& field_name_;
|
|
Array& fields_;
|
|
Field& field_;
|
|
String& func_name_;
|
|
Function& func_;
|
|
Array& call_sites_;
|
|
ICData& call_site_;
|
|
String& target_name_;
|
|
Function& target_;
|
|
Array& args_desc_;
|
|
GrowableObjectArray& functions_to_compile_;
|
|
Object& error_;
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#endif // !defined(DART_PRECOMPILED_RUNTIME)
|
|
|
|
#endif // RUNTIME_VM_COMPILATION_TRACE_H_
|