Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 2223523002: [Interpreter] Avoid dereferencing handles on BytecodeGenerator for AST operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_const_array
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecode-array-writer.cc ('k') | src/interpreter/bytecode-peephole-optimizer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index b4f03b73fd6e547c6d9ec15dbf90c4aa380dbf13..e89107afae072e921fb0c06e39e61b174d151473 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -664,6 +664,10 @@ void BytecodeGenerator::FinalizeBytecode() {
}
void BytecodeGenerator::GenerateBytecode() {
+ DisallowHeapAllocation no_allocation;
+ DisallowHandleAllocation no_handles;
+ DisallowHandleDereference no_deref;
+
// Initialize the incoming context.
ContextScope incoming_context(this, scope(), false);
@@ -1159,7 +1163,8 @@ void BytecodeGenerator::VisitForInAssignment(Expression* expr,
// Evaluate assignment starting with the value to be stored in the
// accumulator.
Property* property = expr->AsProperty();
- LhsKind assign_type = Property::GetAssignType(property);
+ LhsKind assign_type =
+ Property::GetAssignType(property, HandleDereferenceMode::kDisallowed);
switch (assign_type) {
case VARIABLE: {
Variable* variable = expr->AsVariableProxy()->var();
@@ -1638,6 +1643,10 @@ void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
case ObjectLiteral::Property::COMPUTED: {
// It is safe to use [[Put]] here because the boilerplate already
// contains computed properties with an uninitialized value.
+
+ // TODO(5203): Remove this temporary exception.
+ AllowHandleDereference allow_deref;
+
if (literal_key->value()->IsInternalizedString()) {
if (property->emit_store()) {
VisitForAccumulatorValue(property->value());
@@ -2148,7 +2157,8 @@ void BytecodeGenerator::VisitAssignment(Assignment* expr) {
// Left-hand side can only be a property, a global or a variable slot.
Property* property = expr->target()->AsProperty();
- LhsKind assign_type = Property::GetAssignType(property);
+ LhsKind assign_type =
+ Property::GetAssignType(property, HandleDereferenceMode::kDisallowed);
// Evaluate LHS expression.
switch (assign_type) {
@@ -2378,7 +2388,8 @@ void BytecodeGenerator::VisitThrow(Throw* expr) {
}
void BytecodeGenerator::VisitPropertyLoad(Register obj, Property* expr) {
- LhsKind property_kind = Property::GetAssignType(expr);
+ LhsKind property_kind =
+ Property::GetAssignType(expr, HandleDereferenceMode::kDisallowed);
FeedbackVectorSlot slot = expr->PropertyFeedbackSlot();
builder()->SetExpressionPosition(expr);
switch (property_kind) {
@@ -2456,7 +2467,8 @@ void BytecodeGenerator::VisitKeyedSuperPropertyLoad(Property* property,
}
void BytecodeGenerator::VisitProperty(Property* expr) {
- LhsKind property_kind = Property::GetAssignType(expr);
+ LhsKind property_kind =
+ Property::GetAssignType(expr, HandleDereferenceMode::kDisallowed);
if (property_kind != NAMED_SUPER_PROPERTY &&
property_kind != KEYED_SUPER_PROPERTY) {
Register obj = VisitForRegisterValue(expr->obj());
@@ -2500,7 +2512,8 @@ Register BytecodeGenerator::VisitArguments(ZoneList<Expression*>* args) {
void BytecodeGenerator::VisitCall(Call* expr) {
Expression* callee_expr = expr->expression();
- Call::CallType call_type = expr->GetCallType(isolate());
+ Call::CallType call_type =
+ expr->GetCallType(isolate(), HandleDereferenceMode::kDisallowed);
if (call_type == Call::SUPER_CALL) {
return VisitCallSuper(expr);
@@ -2765,7 +2778,9 @@ void BytecodeGenerator::VisitDelete(UnaryOperation* expr) {
// not allowed in strict mode. Deleting 'this' is allowed in both modes.
VariableProxy* proxy = expr->expression()->AsVariableProxy();
Variable* variable = proxy->var();
- DCHECK(is_sloppy(language_mode()) || variable->HasThisName(isolate()));
+ DCHECK(
+ is_sloppy(language_mode()) ||
+ variable->HasThisName(isolate(), HandleDereferenceMode::kDisallowed));
switch (variable->location()) {
case VariableLocation::GLOBAL:
case VariableLocation::UNALLOCATED: {
@@ -2787,7 +2802,8 @@ void BytecodeGenerator::VisitDelete(UnaryOperation* expr) {
case VariableLocation::CONTEXT: {
// Deleting local var/let/const, context variables, and arguments
// does not have any effect.
- if (variable->HasThisName(isolate())) {
+ if (variable->HasThisName(isolate(),
+ HandleDereferenceMode::kDisallowed)) {
builder()->LoadTrue();
} else {
builder()->LoadFalse();
@@ -2818,7 +2834,8 @@ void BytecodeGenerator::VisitCountOperation(CountOperation* expr) {
// Left-hand side can only be a property, a global or a variable slot.
Property* property = expr->expression()->AsProperty();
- LhsKind assign_type = Property::GetAssignType(property);
+ LhsKind assign_type =
+ Property::GetAssignType(property, HandleDereferenceMode::kDisallowed);
bool is_postfix = expr->is_postfix() && !execution_result()->IsEffect();
@@ -3035,6 +3052,18 @@ void BytecodeGenerator::VisitRewritableExpression(RewritableExpression* expr) {
Visit(expr->expression());
}
+namespace {
+
+Handle<ScopeInfo> GetScopeInfo(Scope* scope, Isolate* isolate) {
+ // TODO(5203): Remove this temporary exception.
+ AllowHeapAllocation allow_allocation;
+ AllowHandleAllocation allow_handles;
+ AllowHandleDereference allow_deref;
+ return scope->GetScopeInfo(isolate);
+}
+
+} // namespace
+
void BytecodeGenerator::VisitNewLocalFunctionContext() {
AccumulatorResultScope accumulator_execution_result(this);
Scope* scope = this->scope();
@@ -3048,7 +3077,7 @@ void BytecodeGenerator::VisitNewLocalFunctionContext() {
builder()
->LoadAccumulatorWithRegister(Register::function_closure())
.StoreAccumulatorInRegister(closure)
- .LoadLiteral(scope->GetScopeInfo(isolate()))
+ .LoadLiteral(GetScopeInfo(scope, isolate()))
.StoreAccumulatorInRegister(scope_info)
.CallRuntime(Runtime::kNewScriptContext, closure, 2);
} else {
@@ -3096,7 +3125,7 @@ void BytecodeGenerator::VisitNewLocalBlockContext(Scope* scope) {
Register closure = register_allocator()->NextConsecutiveRegister();
builder()
- ->LoadLiteral(scope->GetScopeInfo(isolate()))
+ ->LoadLiteral(GetScopeInfo(scope, isolate()))
.StoreAccumulatorInRegister(scope_info);
VisitFunctionClosureForContext();
builder()
« no previous file with comments | « src/interpreter/bytecode-array-writer.cc ('k') | src/interpreter/bytecode-peephole-optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698