Reland [parser] Skipping inner funcs: use PodArray for the data.
The data produced by the preparser scope analysis might be large. ByteArrays are already allowed in the large object space. This fixes mjsunit/asm/poppler/poppler.js with the flag on. First version landed as https://chromium-review.googlesource.com/c/484459/ this version includes gen-postmortem-metadata fixes. BUG=v8:5516 Change-Id: I2218c4729ba9feefd6595a93e5cc6d2e52ebda0e Reviewed-on: https://chromium-review.googlesource.com/486641 Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Commit-Queue: Marja Hölttä <marja@chromium.org> Cr-Commit-Position: refs/heads/master@{#44835}
This commit is contained in:
parent
a1af3315a2
commit
0b804e385e
@ -1087,7 +1087,7 @@ MaybeHandle<Code> GetLazyCode(Handle<JSFunction> function) {
|
||||
Handle<Script> script(Script::cast(function->shared()->script()));
|
||||
if (script->HasPreparsedScopeData()) {
|
||||
parse_info.preparsed_scope_data()->Deserialize(
|
||||
script->GetPreparsedScopeData());
|
||||
script->preparsed_scope_data());
|
||||
}
|
||||
}
|
||||
Compiler::ConcurrencyMode inner_function_mode =
|
||||
@ -1182,8 +1182,8 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
|
||||
if (!script.is_null()) {
|
||||
script->set_compilation_state(Script::COMPILATION_STATE_COMPILED);
|
||||
if (FLAG_experimental_preparser_scope_analysis) {
|
||||
Handle<FixedUint32Array> data(
|
||||
parse_info->preparsed_scope_data()->Serialize(isolate));
|
||||
Handle<PodArray<uint32_t>> data =
|
||||
parse_info->preparsed_scope_data()->Serialize(isolate);
|
||||
script->set_preparsed_scope_data(*data);
|
||||
}
|
||||
}
|
||||
|
@ -1127,7 +1127,8 @@ Handle<Script> Factory::NewScript(Handle<String> source) {
|
||||
script->set_eval_from_position(0);
|
||||
script->set_shared_function_infos(*empty_fixed_array(), SKIP_WRITE_BARRIER);
|
||||
script->set_flags(0);
|
||||
script->set_preparsed_scope_data(heap->empty_fixed_uint32_array());
|
||||
script->set_preparsed_scope_data(
|
||||
PodArray<uint32_t>::cast(heap->empty_byte_array()));
|
||||
|
||||
heap->set_script_list(*WeakFixedArray::Add(script_list(), script));
|
||||
return script;
|
||||
|
@ -5816,7 +5816,7 @@ ACCESSORS(Script, source_url, Object, kSourceUrlOffset)
|
||||
ACCESSORS(Script, source_mapping_url, Object, kSourceMappingUrlOffset)
|
||||
ACCESSORS_CHECKED(Script, wasm_compiled_module, Object, kEvalFromSharedOffset,
|
||||
this->type() == TYPE_WASM)
|
||||
ACCESSORS(Script, preparsed_scope_data, FixedTypedArrayBase,
|
||||
ACCESSORS(Script, preparsed_scope_data, PodArray<uint32_t>,
|
||||
kPreParsedScopeDataOffset)
|
||||
|
||||
Script::CompilationType Script::compilation_type() {
|
||||
|
@ -13402,11 +13402,6 @@ bool Script::HasPreparsedScopeData() const {
|
||||
return preparsed_scope_data()->length() > 0;
|
||||
}
|
||||
|
||||
Handle<FixedUint32Array> Script::GetPreparsedScopeData() const {
|
||||
return Handle<FixedUint32Array>::cast(
|
||||
Handle<FixedTypedArrayBase>(preparsed_scope_data()));
|
||||
}
|
||||
|
||||
SharedFunctionInfo::ScriptIterator::ScriptIterator(Handle<Script> script)
|
||||
: ScriptIterator(script->GetIsolate(),
|
||||
handle(script->shared_function_infos())) {}
|
||||
|
@ -5487,7 +5487,7 @@ class Script: public Struct {
|
||||
// This must only be called if the type of this script is TYPE_WASM.
|
||||
DECL_ACCESSORS(wasm_compiled_module, Object)
|
||||
|
||||
DECL_ACCESSORS(preparsed_scope_data, FixedTypedArrayBase)
|
||||
DECL_ACCESSORS(preparsed_scope_data, PodArray<uint32_t>)
|
||||
|
||||
// [compilation_type]: how the the script was compiled. Encoded in the
|
||||
// 'flags' field.
|
||||
@ -5576,7 +5576,6 @@ class Script: public Struct {
|
||||
};
|
||||
|
||||
bool HasPreparsedScopeData() const;
|
||||
Handle<FixedUint32Array> GetPreparsedScopeData() const;
|
||||
|
||||
// Dispatched behavior.
|
||||
DECLARE_PRINTER(Script)
|
||||
|
@ -163,13 +163,14 @@ void PreParsedScopeData::RestoreData(Scope* scope, uint32_t* index_ptr) const {
|
||||
DCHECK_EQ(data_end_index, index);
|
||||
}
|
||||
|
||||
FixedUint32Array* PreParsedScopeData::Serialize(Isolate* isolate) const {
|
||||
Handle<PodArray<uint32_t>> PreParsedScopeData::Serialize(
|
||||
Isolate* isolate) const {
|
||||
// FIXME(marja): save space by using a byte array and converting
|
||||
// function_index_ to bytes.
|
||||
Handle<JSTypedArray> js_array = isolate->factory()->NewJSTypedArray(
|
||||
UINT32_ELEMENTS,
|
||||
function_index_.size() * kFunctionDataSize + backing_store_.size() + 1);
|
||||
FixedUint32Array* array = FixedUint32Array::cast(js_array->elements());
|
||||
size_t length =
|
||||
function_index_.size() * kFunctionDataSize + backing_store_.size() + 1;
|
||||
Handle<PodArray<uint32_t>> array =
|
||||
PodArray<uint32_t>::New(isolate, static_cast<int>(length), TENURED);
|
||||
|
||||
array->set(0, static_cast<uint32_t>(function_index_.size()));
|
||||
int i = 1;
|
||||
@ -192,33 +193,31 @@ FixedUint32Array* PreParsedScopeData::Serialize(Isolate* isolate) const {
|
||||
return array;
|
||||
}
|
||||
|
||||
void PreParsedScopeData::Deserialize(Handle<FixedUint32Array> array) {
|
||||
void PreParsedScopeData::Deserialize(PodArray<uint32_t>* array) {
|
||||
has_data_ = true;
|
||||
DCHECK(!array.is_null());
|
||||
DCHECK_NOT_NULL(array);
|
||||
if (array->length() == 0) {
|
||||
return;
|
||||
}
|
||||
int function_count = array->get_scalar(0);
|
||||
int function_count = array->get(0);
|
||||
CHECK(array->length() > function_count * kFunctionDataSize);
|
||||
if (function_count == 0) {
|
||||
return;
|
||||
}
|
||||
int i = 1;
|
||||
for (; i < function_count * kFunctionDataSize + 1; i += kFunctionDataSize) {
|
||||
int start = array->get_scalar(i);
|
||||
function_data_positions_[start] = array->get_scalar(i + 1);
|
||||
int start = array->get(i);
|
||||
function_data_positions_[start] = array->get(i + 1);
|
||||
function_index_.AddFunctionData(
|
||||
start,
|
||||
PreParseData::FunctionData(
|
||||
array->get_scalar(i + 2), array->get_scalar(i + 3),
|
||||
array->get_scalar(i + 4), LanguageMode(array->get_scalar(i + 5)),
|
||||
array->get_scalar(i + 6)));
|
||||
start, PreParseData::FunctionData(
|
||||
array->get(i + 2), array->get(i + 3), array->get(i + 4),
|
||||
LanguageMode(array->get(i + 5)), array->get(i + 6)));
|
||||
}
|
||||
CHECK_EQ(function_index_.size(), function_count);
|
||||
|
||||
backing_store_.reserve(array->length() - i);
|
||||
for (; i < array->length(); ++i) {
|
||||
backing_store_.push_back(array->get_scalar(i));
|
||||
backing_store_.push_back(array->get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,8 +82,8 @@ class PreParsedScopeData {
|
||||
void RestoreData(Scope* scope, uint32_t* index_ptr) const;
|
||||
void RestoreData(DeclarationScope* scope) const;
|
||||
|
||||
FixedUint32Array* Serialize(Isolate* isolate) const;
|
||||
void Deserialize(Handle<FixedUint32Array> array);
|
||||
Handle<PodArray<uint32_t>> Serialize(Isolate* isolate) const;
|
||||
void Deserialize(PodArray<uint32_t>* array);
|
||||
|
||||
bool Consuming() const { return has_data_; }
|
||||
|
||||
|
@ -493,7 +493,7 @@ def parse_field(call):
|
||||
if (kind == 'ACCESSORS' or kind == 'ACCESSORS_GCSAFE'):
|
||||
klass = args[0];
|
||||
field = args[1];
|
||||
dtype = args[2];
|
||||
dtype = args[2].replace('<', '_').replace('>', '_')
|
||||
offset = args[3];
|
||||
|
||||
return ({
|
||||
|
Loading…
Reference in New Issue
Block a user