Commit 7f2fc562 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

Drop parameter names from ScopeInfo

Change-Id: I5fd42cd70aaba15cfef32eea54232f8292aaa874
Reviewed-on: https://chromium-review.googlesource.com/1105775Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53841}
parent 2ebd3ed2
......@@ -2004,13 +2004,6 @@ void JavaScriptFrame::Print(StringStream* accumulator,
int parameters_count = ComputeParametersCount();
for (int i = 0; i < parameters_count; i++) {
accumulator->Add(",");
// If we have a name for the parameter we print it. Nameless
// parameters are either because we have more actual parameters
// than formal parameters or because we have no scope information.
if (i < scope_info->ParameterCount()) {
accumulator->PrintName(scope_info->ParameterName(i));
accumulator->Add("=");
}
accumulator->Add("%o", GetParameter(i));
}
......
......@@ -1176,10 +1176,14 @@ class DebugInfoSection : public DebugSection {
int internal_slots = Context::MIN_CONTEXT_SLOTS;
int current_abbreviation = 4;
EmbeddedVector<char, 256> buffer;
StringBuilder builder(buffer.start(), buffer.length());
for (int param = 0; param < params; ++param) {
w->WriteULEB128(current_abbreviation++);
w->WriteString(
scope->ParameterName(param)->ToCString(DISALLOW_NULLS).get());
builder.Reset();
builder.AddFormatted("param%d", param);
w->WriteString(builder.Finalize());
w->Write<uint32_t>(ty_offset);
Writer::Slot<uint32_t> block_size = w->CreateSlotHere<uint32_t>();
uintptr_t block_start = w->position();
......@@ -1190,9 +1194,6 @@ class DebugInfoSection : public DebugSection {
block_size.set(static_cast<uint32_t>(w->position() - block_start));
}
EmbeddedVector<char, 256> buffer;
StringBuilder builder(buffer.start(), buffer.length());
// See contexts.h for more information.
DCHECK_EQ(Context::MIN_CONTEXT_SLOTS, 4);
DCHECK_EQ(Context::SCOPE_INFO_INDEX, 0);
......
......@@ -2023,8 +2023,6 @@ void ScopeInfo::ScopeInfoPrint(std::ostream& os) { // NOLINT
}
os << "\n - length: " << length();
if (length() > 0) {
PrintScopeInfoList(this, os, "parameters", 0, ParameterNamesIndex(),
ParameterCount());
PrintScopeInfoList(this, os, "context slots", Context::MIN_CONTEXT_SLOTS,
ContextLocalNamesIndex(), ContextLocalCount());
// TODO(neis): Print module stuff if present.
......
......@@ -139,8 +139,8 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
const bool has_receiver = receiver_info == STACK || receiver_info == CONTEXT;
const int parameter_count = scope->num_parameters();
const bool has_outer_scope_info = !outer_scope.is_null();
const int length = kVariablePartIndex + parameter_count +
2 * context_local_count + (has_receiver ? 1 : 0) +
const int length = kVariablePartIndex + 2 * context_local_count +
(has_receiver ? 1 : 0) +
(has_function_name ? kFunctionNameEntries : 0) +
(has_inferred_function_name ? 1 : 0) +
(has_position_info ? kPositionInfoEntries : 0) +
......@@ -187,14 +187,6 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
scope_info->SetContextLocalCount(context_local_count);
int index = kVariablePartIndex;
// Add parameters.
DCHECK_EQ(index, scope_info->ParameterNamesIndex());
if (scope->is_declaration_scope()) {
for (int i = 0; i < parameter_count; ++i) {
scope_info->set(index++,
*scope->AsDeclarationScope()->parameter(i)->name());
}
}
// Add context locals' names and info, module variables' names and info.
// Context locals are added using their index.
......@@ -350,7 +342,6 @@ Handle<ScopeInfo> ScopeInfo::CreateForWithScope(
scope_info->SetContextLocalCount(0);
int index = kVariablePartIndex;
DCHECK_EQ(index, scope_info->ParameterNamesIndex());
DCHECK_EQ(index, scope_info->ReceiverInfoIndex());
DCHECK_EQ(index, scope_info->FunctionNameInfoIndex());
DCHECK_EQ(index, scope_info->InferredFunctionNameIndex());
......@@ -387,8 +378,8 @@ Handle<ScopeInfo> ScopeInfo::CreateForBootstrapping(Isolate* isolate,
const bool has_receiver = !is_empty_function;
const bool has_inferred_function_name = is_empty_function;
const bool has_position_info = true;
const int length = kVariablePartIndex + parameter_count +
2 * context_local_count + (has_receiver ? 1 : 0) +
const int length = kVariablePartIndex + 2 * context_local_count +
(has_receiver ? 1 : 0) +
(is_empty_function ? kFunctionNameEntries : 0) +
(has_inferred_function_name ? 1 : 0) +
(has_position_info ? kPositionInfoEntries : 0);
......@@ -630,13 +621,6 @@ ModuleInfo* ScopeInfo::ModuleDescriptorInfo() const {
return ModuleInfo::cast(get(ModuleInfoIndex()));
}
String* ScopeInfo::ParameterName(int var) const {
DCHECK_LE(0, var);
DCHECK_LT(var, ParameterCount());
int info_index = ParameterNamesIndex() + var;
return String::cast(get(info_index));
}
String* ScopeInfo::ContextLocalName(int var) const {
DCHECK_LE(0, var);
DCHECK_LT(var, ContextLocalCount());
......@@ -775,24 +759,6 @@ int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info,
return -1;
}
int ScopeInfo::ParameterIndex(String* name) const {
DCHECK(name->IsInternalizedString());
if (length() == 0) return -1;
// We must read parameters from the end since for
// multiply declared parameters the value of the
// last declaration of that parameter is used
// inside a function (and thus we need to look
// at the last index). Was bug# 1110337.
int start = ParameterNamesIndex();
int end = start + ParameterCount();
for (int i = end - 1; i >= start; --i) {
if (name == get(i)) {
return i - start;
}
}
return -1;
}
int ScopeInfo::ReceiverContextSlotIndex() const {
if (length() > 0 && ReceiverVariableField::decode(Flags()) == CONTEXT) {
return Smi::ToInt(get(ReceiverInfoIndex()));
......@@ -815,15 +781,11 @@ FunctionKind ScopeInfo::function_kind() const {
return FunctionKindField::decode(Flags());
}
int ScopeInfo::ParameterNamesIndex() const {
int ScopeInfo::ContextLocalNamesIndex() const {
DCHECK_LT(0, length());
return kVariablePartIndex;
}
int ScopeInfo::ContextLocalNamesIndex() const {
return ParameterNamesIndex() + ParameterCount();
}
int ScopeInfo::ContextLocalInfosIndex() const {
return ContextLocalNamesIndex() + ContextLocalCount();
}
......
......@@ -108,9 +108,6 @@ class ScopeInfo : public FixedArray {
ModuleInfo* ModuleDescriptorInfo() const;
// Return the name of the given parameter.
String* ParameterName(int var) const;
// Return the name of the given context local.
String* ContextLocalName(int var) const;
......@@ -146,11 +143,6 @@ class ScopeInfo : public FixedArray {
InitializationFlag* init_flag,
MaybeAssignedFlag* maybe_assigned_flag);
// Lookup support for serialized scope info. Returns the
// parameter index for a given parameter name if the parameter is present;
// otherwise returns a value < 0. The name must be an internalized string.
int ParameterIndex(String* name) const;
// Lookup support for serialized scope info. Returns the function context
// slot index if the function name is present and context-allocated (named
// function expressions, only), otherwise returns a value < 0. The name
......@@ -217,42 +209,36 @@ class ScopeInfo : public FixedArray {
private:
// The layout of the variable part of a ScopeInfo is as follows:
// 1. ParameterNames:
// This part stores the names of the parameters for function scopes. One
// slot is used per parameter, so in total this part occupies
// ParameterCount() slots in the array. For other scopes than function
// scopes ParameterCount() is 0.
// 2. ContextLocalNames:
// 1. ContextLocalNames:
// Contains the names of local variables and parameters that are allocated
// in the context. They are stored in increasing order of the context slot
// index starting with Context::MIN_CONTEXT_SLOTS. One slot is used per
// context local, so in total this part occupies ContextLocalCount() slots
// in the array.
// 3. ContextLocalInfos:
// 2. ContextLocalInfos:
// Contains the variable modes and initialization flags corresponding to
// the context locals in ContextLocalNames. One slot is used per
// context local, so in total this part occupies ContextLocalCount()
// slots in the array.
// 4. ReceiverInfo:
// 3. ReceiverInfo:
// If the scope binds a "this" value, one slot is reserved to hold the
// context or stack slot index for the variable.
// 5. FunctionNameInfo:
// 4. FunctionNameInfo:
// If the scope belongs to a named function expression this part contains
// information about the function variable. It always occupies two array
// slots: a. The name of the function variable.
// b. The context or stack slot index for the variable.
// 6. InferredFunctionName:
// 5. InferredFunctionName:
// Contains the function's inferred name.
// 7. SourcePosition:
// 6. SourcePosition:
// Contains two slots with a) the startPosition and b) the endPosition if
// the scope belongs to a function or script.
// 8. OuterScopeInfoIndex:
// 7. OuterScopeInfoIndex:
// The outer scope's ScopeInfo or the hole if there's none.
// 9. ModuleInfo, ModuleVariableCount, and ModuleVariables:
// 8. ModuleInfo, ModuleVariableCount, and ModuleVariables:
// For a module scope, this part contains the ModuleInfo, the number of
// MODULE-allocated variables, and the metadata of those variables. For
// non-module scopes it is empty.
int ParameterNamesIndex() const;
int ContextLocalNamesIndex() const;
int ContextLocalInfosIndex() const;
int ReceiverInfoIndex() const;
......
......@@ -343,7 +343,7 @@ TEST(HeapSnapshotCodeObjects) {
CompileRun(
"function lazy(x) { return x - 1; }\n"
"function compiled(x) { return x + 1; }\n"
"function compiled(x) { ()=>x; return x + 1; }\n"
"var anonymous = (function() { return function() { return 0; } })();\n"
"compiled(1)");
const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot();
......
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