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

Unified Diff: src/compiler/ast-graph-builder.cc

Issue 985643003: [es6] Throw TypeError for computed static prototype property name (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Inline BuildThrowStaticPrototype Created 5 years, 9 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/compiler/ast-graph-builder.h ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc
index 96809fc2dff053b92817c2ffd0bdf7ad66a819d5..8fb25bf3c359ae6e0ead9ad75a1aee633d2f8146 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -1402,6 +1402,17 @@ void AstGraphBuilder::VisitClassLiteralContents(ClassLiteral* expr) {
VisitForValue(property->key());
environment()->Push(
BuildToName(environment()->Pop(), expr->GetIdForProperty(i)));
+
+ // The static prototype property is read only. We handle the non computed
+ // property name case in the parser. Since this is the only case where we
+ // need to check for an own read only property we special case this so we do
+ // not need to do this for every property.
+ if (property->is_static() && property->is_computed_name()) {
+ Node* name = environment()->Pop();
+ environment()->Push(
+ BuildThrowIfStaticPrototype(name, expr->GetIdForProperty(i)));
+ }
+
VisitForValue(property->value());
Node* value = environment()->Pop();
Node* key = environment()->Pop();
@@ -2582,6 +2593,28 @@ Node* AstGraphBuilder::BuildHoleCheckThrow(Node* value, Variable* variable,
}
+Node* AstGraphBuilder::BuildThrowIfStaticPrototype(Node* name,
+ BailoutId bailout_id) {
+ IfBuilder prototype_check(this);
+ Node* prototype_string =
+ jsgraph()->Constant(isolate()->factory()->prototype_string());
+ Node* check = NewNode(javascript()->StrictEqual(), name, prototype_string);
+ prototype_check.If(check);
+ prototype_check.Then();
+ {
+ const Operator* op =
+ javascript()->CallRuntime(Runtime::kThrowStaticPrototypeError, 0);
+ Node* call = NewNode(op);
+ PrepareFrameState(call, bailout_id);
+ environment()->Push(call);
+ }
+ prototype_check.Else();
+ environment()->Push(name);
+ prototype_check.End();
+ return environment()->Pop();
+}
+
+
Node* AstGraphBuilder::BuildVariableLoad(Variable* variable,
BailoutId bailout_id,
const VectorSlotPair& feedback,
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698