[torque] hide internal variables used for labels with parameters

This fixes a bug that the variables used to implement labels with
parameters in CSA leak into the user-accessible scope.

Example:

macro Foo() labels Bar(Smi) {
  Bar0 = 5;
}

Bug: v8:7793
Change-Id: I33bf5a207c7e9e7337fa79fc7591c05901b2fa5b
Reviewed-on: https://chromium-review.googlesource.com/1246183
Reviewed-by: Daniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56257}
This commit is contained in:
Tobias Tebbi 2018-09-26 17:01:24 +02:00 committed by Commit Bot
parent 0ba3de6089
commit 1c2d611145
3 changed files with 13 additions and 1 deletions

View File

@ -638,7 +638,8 @@ void DeclarationVisitor::DeclareSignature(const Signature& signature) {
}
std::string var_name = label.name + std::to_string(i++);
new_label->AddVariable(DeclareVariable(var_name, var_type, false));
new_label->AddVariable(
declarations()->CreateVariable(var_name, var_type, false));
}
}
}

View File

@ -304,6 +304,15 @@ RuntimeFunction* Declarations::DeclareRuntimeFunction(
return result;
}
Variable* Declarations::CreateVariable(const std::string& var, const Type* type,
bool is_const) {
std::string name(var + "_" +
std::to_string(GetNextUniqueDeclarationNumber()));
std::replace(name.begin(), name.end(), '.', '_');
return RegisterDeclarable(
std::unique_ptr<Variable>(new Variable(var, name, type, is_const)));
}
Variable* Declarations::DeclareVariable(const std::string& var,
const Type* type, bool is_const) {
std::string name(var + "_" +

View File

@ -91,6 +91,8 @@ class Declarations {
RuntimeFunction* DeclareRuntimeFunction(const std::string& name,
const Signature& signature);
Variable* CreateVariable(const std::string& var, const Type* type,
bool is_const);
Variable* DeclareVariable(const std::string& var, const Type* type,
bool is_const);