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

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: 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
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index 7a1a7a051154bf4c583f4a02460b1f61be3bc5fe..1c097ee0be7168c41179cf8ae41d4545e43d6520 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);
@@ -1158,7 +1162,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::kHandleDereferenceDisallowed);
switch (assign_type) {
case VARIABLE: {
Variable* variable = expr->AsVariableProxy()->var();
@@ -1637,6 +1642,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());
@@ -2145,7 +2154,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::kHandleDereferenceDisallowed);
// Evaluate LHS expression.
switch (assign_type) {
@@ -2372,7 +2382,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::kHandleDereferenceDisallowed);
FeedbackVectorSlot slot = expr->PropertyFeedbackSlot();
builder()->SetExpressionPosition(expr);
switch (property_kind) {
@@ -2450,7 +2461,8 @@ void BytecodeGenerator::VisitKeyedSuperPropertyLoad(Property* property,
}
void BytecodeGenerator::VisitProperty(Property* expr) {
- LhsKind property_kind = Property::GetAssignType(expr);
+ LhsKind property_kind = Property::GetAssignType(
+ expr, HandleDereferenceMode::kHandleDereferenceDisallowed);
if (property_kind != NAMED_SUPER_PROPERTY &&
property_kind != KEYED_SUPER_PROPERTY) {
Register obj = VisitForRegisterValue(expr->obj());
@@ -2494,7 +2506,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::kHandleDereferenceDisallowed);
if (call_type == Call::SUPER_CALL) {
return VisitCallSuper(expr);
@@ -2759,7 +2772,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::kHandleDereferenceDisallowed));
switch (variable->location()) {
case VariableLocation::GLOBAL:
case VariableLocation::UNALLOCATED: {
@@ -2781,7 +2796,9 @@ 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::kHandleDereferenceDisallowed)) {
builder()->LoadTrue();
} else {
builder()->LoadFalse();
@@ -2812,7 +2829,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::kHandleDereferenceDisallowed);
bool is_postfix = expr->is_postfix() && !execution_result()->IsEffect();
@@ -3033,6 +3051,11 @@ void BytecodeGenerator::VisitNewLocalFunctionContext() {
// Allocate a new local context.
if (scope->is_script_scope()) {
+ // TODO(5203): Remove this temporary exception.
+ AllowHeapAllocation allow_allocation;
+ AllowHandleAllocation allow_handles;
+ AllowHandleDereference allow_deref;
+
RegisterAllocationScope register_scope(this);
Register closure = register_allocator()->NewRegister();
Register scope_info = register_allocator()->NewRegister();
@@ -3079,6 +3102,11 @@ void BytecodeGenerator::VisitBuildLocalActivationContext() {
}
void BytecodeGenerator::VisitNewLocalBlockContext(Scope* scope) {
+ // TODO(5203): Remove this temporary exception.
+ AllowHeapAllocation allow_allocation;
+ AllowHandleAllocation allow_handles;
+ AllowHandleDereference allow_deref;
+
AccumulatorResultScope accumulator_execution_result(this);
DCHECK(scope->is_block_scope());

Powered by Google App Engine
This is Rietveld 408576698