Commit 7f7d445f authored by Franziska Hinkelmann's avatar Franziska Hinkelmann Committed by Commit Bot

Revert "[parser] Skipping inner funcs: use PodArray for the data."

This reverts commit e8f1fc24.

Reason for revert: Node.js doesn't build with this patch anymore. 

out/Release/obj/gen/debug-support.cc:428:55: error: expected initializer before ‘<’ token
 int v8dbg_class_Script__preparsed_scope_data__PodArray<uint32_t> = Script::kPreParsedScopeDataOffset;

Original change's description:
> [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.
> 
> BUG=v8:5516
> 
> Change-Id: I951836244776c57efdd2a491c5c78493dc8cca63
> Reviewed-on: https://chromium-review.googlesource.com/484459
> Commit-Queue: Marja Hölttä <marja@chromium.org>
> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#44795}

TBR=marja@chromium.org,mstarzinger@chromium.org,ulan@chromium.org,vogelheim@chromium.org,hpayer@chromium.org,v8-reviews@googlegroups.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:5516

Change-Id: I3012d27b6b65b37d3afc5f3b0921e044bdcc118e
Reviewed-on: https://chromium-review.googlesource.com/485759Reviewed-by: 's avatarFranziska Hinkelmann <franzih@chromium.org>
Commit-Queue: Franziska Hinkelmann <franzih@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44805}
parent 4968b2c4
......@@ -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->preparsed_scope_data());
script->GetPreparsedScopeData());
}
}
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<PodArray<uint32_t>> data =
parse_info->preparsed_scope_data()->Serialize(isolate);
Handle<FixedUint32Array> data(
parse_info->preparsed_scope_data()->Serialize(isolate));
script->set_preparsed_scope_data(*data);
}
}
......
......@@ -1127,8 +1127,7 @@ 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(
PodArray<uint32_t>::cast(heap->empty_byte_array()));
script->set_preparsed_scope_data(heap->empty_fixed_uint32_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, PodArray<uint32_t>,
ACCESSORS(Script, preparsed_scope_data, FixedTypedArrayBase,
kPreParsedScopeDataOffset)
Script::CompilationType Script::compilation_type() {
......
......@@ -13398,6 +13398,11 @@ 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, PodArray<uint32_t>)
DECL_ACCESSORS(preparsed_scope_data, FixedTypedArrayBase)
// [compilation_type]: how the the script was compiled. Encoded in the
// 'flags' field.
......@@ -5576,6 +5576,7 @@ class Script: public Struct {
};
bool HasPreparsedScopeData() const;
Handle<FixedUint32Array> GetPreparsedScopeData() const;
// Dispatched behavior.
DECLARE_PRINTER(Script)
......
......@@ -163,14 +163,13 @@ void PreParsedScopeData::RestoreData(Scope* scope, uint32_t* index_ptr) const {
DCHECK_EQ(data_end_index, index);
}
Handle<PodArray<uint32_t>> PreParsedScopeData::Serialize(
Isolate* isolate) const {
FixedUint32Array* PreParsedScopeData::Serialize(Isolate* isolate) const {
// FIXME(marja): save space by using a byte array and converting
// function_index_ to bytes.
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);
Handle<JSTypedArray> js_array = isolate->factory()->NewJSTypedArray(
UINT32_ELEMENTS,
function_index_.size() * kFunctionDataSize + backing_store_.size() + 1);
FixedUint32Array* array = FixedUint32Array::cast(js_array->elements());
array->set(0, static_cast<uint32_t>(function_index_.size()));
int i = 1;
......@@ -193,31 +192,33 @@ Handle<PodArray<uint32_t>> PreParsedScopeData::Serialize(
return array;
}
void PreParsedScopeData::Deserialize(PodArray<uint32_t>* array) {
void PreParsedScopeData::Deserialize(Handle<FixedUint32Array> array) {
has_data_ = true;
DCHECK_NOT_NULL(array);
DCHECK(!array.is_null());
if (array->length() == 0) {
return;
}
int function_count = array->get(0);
int function_count = array->get_scalar(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(i);
function_data_positions_[start] = array->get(i + 1);
int start = array->get_scalar(i);
function_data_positions_[start] = array->get_scalar(i + 1);
function_index_.AddFunctionData(
start, PreParseData::FunctionData(
array->get(i + 2), array->get(i + 3), array->get(i + 4),
LanguageMode(array->get(i + 5)), array->get(i + 6)));
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)));
}
CHECK_EQ(function_index_.size(), function_count);
backing_store_.reserve(array->length() - i);
for (; i < array->length(); ++i) {
backing_store_.push_back(array->get(i));
backing_store_.push_back(array->get_scalar(i));
}
}
......
......@@ -82,8 +82,8 @@ class PreParsedScopeData {
void RestoreData(Scope* scope, uint32_t* index_ptr) const;
void RestoreData(DeclarationScope* scope) const;
Handle<PodArray<uint32_t>> Serialize(Isolate* isolate) const;
void Deserialize(PodArray<uint32_t>* array);
FixedUint32Array* Serialize(Isolate* isolate) const;
void Deserialize(Handle<FixedUint32Array> array);
bool Consuming() const { return has_data_; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment