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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 894683003: Introduce LanguageMode, drop StrictMode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: . Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 NewNode(op, receiver, key, value); 923 NewNode(op, receiver, key, value);
924 break; 924 break;
925 } 925 }
926 } 926 }
927 927
928 // TODO(mstarzinger): This is temporary to make "super" work and replicates 928 // TODO(mstarzinger): This is temporary to make "super" work and replicates
929 // the existing FullCodeGenerator::NeedsHomeObject predicate. 929 // the existing FullCodeGenerator::NeedsHomeObject predicate.
930 if (FunctionLiteral::NeedsHomeObject(property->value())) { 930 if (FunctionLiteral::NeedsHomeObject(property->value())) {
931 Unique<Name> name = 931 Unique<Name> name =
932 MakeUnique(isolate()->factory()->home_object_symbol()); 932 MakeUnique(isolate()->factory()->home_object_symbol());
933 Node* store = NewNode(javascript()->StoreNamed(strict_mode(), name), 933 Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
934 value, receiver); 934 value, receiver);
935 PrepareFrameState(store, BailoutId::None()); 935 PrepareFrameState(store, BailoutId::None());
936 } 936 }
937 } 937 }
938 938
939 // Transform both the class literal and the prototype to fast properties. 939 // Transform both the class literal and the prototype to fast properties.
940 const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties, 1); 940 const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties, 1);
941 NewNode(op, environment()->Pop()); // prototype 941 NewNode(op, environment()->Pop()); // prototype
942 NewNode(op, environment()->Pop()); // literal 942 NewNode(op, environment()->Pop()); // literal
943 943
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); 1043 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value()));
1044 // Fall through. 1044 // Fall through.
1045 case ObjectLiteral::Property::COMPUTED: { 1045 case ObjectLiteral::Property::COMPUTED: {
1046 // It is safe to use [[Put]] here because the boilerplate already 1046 // It is safe to use [[Put]] here because the boilerplate already
1047 // contains computed properties with an uninitialized value. 1047 // contains computed properties with an uninitialized value.
1048 if (key->value()->IsInternalizedString()) { 1048 if (key->value()->IsInternalizedString()) {
1049 if (property->emit_store()) { 1049 if (property->emit_store()) {
1050 VisitForValue(property->value()); 1050 VisitForValue(property->value());
1051 Node* value = environment()->Pop(); 1051 Node* value = environment()->Pop();
1052 Unique<Name> name = MakeUnique(key->AsPropertyName()); 1052 Unique<Name> name = MakeUnique(key->AsPropertyName());
1053 Node* store = NewNode(javascript()->StoreNamed(strict_mode(), name), 1053 Node* store =
1054 literal, value); 1054 NewNode(javascript()->StoreNamed(language_mode(), name),
1055 literal, value);
1055 PrepareFrameState(store, key->id()); 1056 PrepareFrameState(store, key->id());
1056 } else { 1057 } else {
1057 VisitForEffect(property->value()); 1058 VisitForEffect(property->value());
1058 } 1059 }
1059 break; 1060 break;
1060 } 1061 }
1061 environment()->Push(literal); // Duplicate receiver. 1062 environment()->Push(literal); // Duplicate receiver.
1062 VisitForValue(property->key()); 1063 VisitForValue(property->key());
1063 VisitForValue(property->value()); 1064 VisitForValue(property->value());
1064 Node* value = environment()->Pop(); 1065 Node* value = environment()->Pop();
1065 Node* key = environment()->Pop(); 1066 Node* key = environment()->Pop();
1066 Node* receiver = environment()->Pop(); 1067 Node* receiver = environment()->Pop();
1067 if (property->emit_store()) { 1068 if (property->emit_store()) {
1068 Node* strict = jsgraph()->Constant(SLOPPY); 1069 Node* language = jsgraph()->Constant(SLOPPY);
1069 const Operator* op = 1070 const Operator* op =
1070 javascript()->CallRuntime(Runtime::kSetProperty, 4); 1071 javascript()->CallRuntime(Runtime::kSetProperty, 4);
1071 NewNode(op, receiver, key, value, strict); 1072 NewNode(op, receiver, key, value, language);
1072 } 1073 }
1073 break; 1074 break;
1074 } 1075 }
1075 case ObjectLiteral::Property::PROTOTYPE: { 1076 case ObjectLiteral::Property::PROTOTYPE: {
1076 environment()->Push(literal); // Duplicate receiver. 1077 environment()->Push(literal); // Duplicate receiver.
1077 VisitForValue(property->value()); 1078 VisitForValue(property->value());
1078 Node* value = environment()->Pop(); 1079 Node* value = environment()->Pop();
1079 Node* receiver = environment()->Pop(); 1080 Node* receiver = environment()->Pop();
1080 DCHECK(property->emit_store()); 1081 DCHECK(property->emit_store());
1081 const Operator* op = 1082 const Operator* op =
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 1206
1206 // Create nodes to evaluate all the non-constant subexpressions and to store 1207 // Create nodes to evaluate all the non-constant subexpressions and to store
1207 // them into the newly cloned array. 1208 // them into the newly cloned array.
1208 for (int i = 0; i < expr->values()->length(); i++) { 1209 for (int i = 0; i < expr->values()->length(); i++) {
1209 Expression* subexpr = expr->values()->at(i); 1210 Expression* subexpr = expr->values()->at(i);
1210 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1211 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1211 1212
1212 VisitForValue(subexpr); 1213 VisitForValue(subexpr);
1213 Node* value = environment()->Pop(); 1214 Node* value = environment()->Pop();
1214 Node* index = jsgraph()->Constant(i); 1215 Node* index = jsgraph()->Constant(i);
1215 Node* store = NewNode(javascript()->StoreProperty(strict_mode()), literal, 1216 Node* store = NewNode(javascript()->StoreProperty(language_mode()), literal,
1216 index, value); 1217 index, value);
1217 PrepareFrameState(store, expr->GetIdForElement(i)); 1218 PrepareFrameState(store, expr->GetIdForElement(i));
1218 } 1219 }
1219 1220
1220 environment()->Pop(); // Array literal index. 1221 environment()->Pop(); // Array literal index.
1221 ast_context()->ProduceValue(environment()->Pop()); 1222 ast_context()->ProduceValue(environment()->Pop());
1222 } 1223 }
1223 1224
1224 1225
1225 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value, 1226 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value,
(...skipping 11 matching lines...) Expand all
1237 BuildVariableAssignment(var, value, Token::ASSIGN, bailout_id); 1238 BuildVariableAssignment(var, value, Token::ASSIGN, bailout_id);
1238 break; 1239 break;
1239 } 1240 }
1240 case NAMED_PROPERTY: { 1241 case NAMED_PROPERTY: {
1241 environment()->Push(value); 1242 environment()->Push(value);
1242 VisitForValue(property->obj()); 1243 VisitForValue(property->obj());
1243 Node* object = environment()->Pop(); 1244 Node* object = environment()->Pop();
1244 value = environment()->Pop(); 1245 value = environment()->Pop();
1245 Unique<Name> name = 1246 Unique<Name> name =
1246 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); 1247 MakeUnique(property->key()->AsLiteral()->AsPropertyName());
1247 Node* store = 1248 Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
1248 NewNode(javascript()->StoreNamed(strict_mode(), name), object, value); 1249 object, value);
1249 PrepareFrameState(store, bailout_id); 1250 PrepareFrameState(store, bailout_id);
1250 break; 1251 break;
1251 } 1252 }
1252 case KEYED_PROPERTY: { 1253 case KEYED_PROPERTY: {
1253 environment()->Push(value); 1254 environment()->Push(value);
1254 VisitForValue(property->obj()); 1255 VisitForValue(property->obj());
1255 VisitForValue(property->key()); 1256 VisitForValue(property->key());
1256 Node* key = environment()->Pop(); 1257 Node* key = environment()->Pop();
1257 Node* object = environment()->Pop(); 1258 Node* object = environment()->Pop();
1258 value = environment()->Pop(); 1259 value = environment()->Pop();
1259 Node* store = NewNode(javascript()->StoreProperty(strict_mode()), object, 1260 Node* store = NewNode(javascript()->StoreProperty(language_mode()),
1260 key, value); 1261 object, key, value);
1261 PrepareFrameState(store, bailout_id); 1262 PrepareFrameState(store, bailout_id);
1262 break; 1263 break;
1263 } 1264 }
1264 } 1265 }
1265 } 1266 }
1266 1267
1267 1268
1268 void AstGraphBuilder::VisitAssignment(Assignment* expr) { 1269 void AstGraphBuilder::VisitAssignment(Assignment* expr) {
1269 DCHECK(expr->target()->IsValidReferenceExpression()); 1270 DCHECK(expr->target()->IsValidReferenceExpression());
1270 1271
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 case VARIABLE: { 1340 case VARIABLE: {
1340 Variable* variable = expr->target()->AsVariableProxy()->var(); 1341 Variable* variable = expr->target()->AsVariableProxy()->var();
1341 BuildVariableAssignment(variable, value, expr->op(), expr->AssignmentId(), 1342 BuildVariableAssignment(variable, value, expr->op(), expr->AssignmentId(),
1342 ast_context()->GetStateCombine()); 1343 ast_context()->GetStateCombine());
1343 break; 1344 break;
1344 } 1345 }
1345 case NAMED_PROPERTY: { 1346 case NAMED_PROPERTY: {
1346 Node* object = environment()->Pop(); 1347 Node* object = environment()->Pop();
1347 Unique<Name> name = 1348 Unique<Name> name =
1348 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); 1349 MakeUnique(property->key()->AsLiteral()->AsPropertyName());
1349 Node* store = 1350 Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
1350 NewNode(javascript()->StoreNamed(strict_mode(), name), object, value); 1351 object, value);
1351 PrepareFrameState(store, expr->AssignmentId(), 1352 PrepareFrameState(store, expr->AssignmentId(),
1352 ast_context()->GetStateCombine()); 1353 ast_context()->GetStateCombine());
1353 break; 1354 break;
1354 } 1355 }
1355 case KEYED_PROPERTY: { 1356 case KEYED_PROPERTY: {
1356 Node* key = environment()->Pop(); 1357 Node* key = environment()->Pop();
1357 Node* object = environment()->Pop(); 1358 Node* object = environment()->Pop();
1358 Node* store = NewNode(javascript()->StoreProperty(strict_mode()), object, 1359 Node* store = NewNode(javascript()->StoreProperty(language_mode()),
1359 key, value); 1360 object, key, value);
1360 PrepareFrameState(store, expr->AssignmentId(), 1361 PrepareFrameState(store, expr->AssignmentId(),
1361 ast_context()->GetStateCombine()); 1362 ast_context()->GetStateCombine());
1362 break; 1363 break;
1363 } 1364 }
1364 } 1365 }
1365 1366
1366 ast_context()->ProduceValue(value); 1367 ast_context()->ProduceValue(value);
1367 } 1368 }
1368 1369
1369 1370
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 int arg_count = args->length(); 1493 int arg_count = args->length();
1493 1494
1494 // Extract callee and source string from the environment. 1495 // Extract callee and source string from the environment.
1495 Node* callee = environment()->Peek(arg_count + 1); 1496 Node* callee = environment()->Peek(arg_count + 1);
1496 Node* source = environment()->Peek(arg_count - 1); 1497 Node* source = environment()->Peek(arg_count - 1);
1497 1498
1498 // Create node to ask for help resolving potential eval call. This will 1499 // Create node to ask for help resolving potential eval call. This will
1499 // provide a fully resolved callee and the corresponding receiver. 1500 // provide a fully resolved callee and the corresponding receiver.
1500 Node* function = GetFunctionClosure(); 1501 Node* function = GetFunctionClosure();
1501 Node* receiver = environment()->Lookup(info()->scope()->receiver()); 1502 Node* receiver = environment()->Lookup(info()->scope()->receiver());
1502 Node* strict = jsgraph()->Constant(strict_mode()); 1503 Node* language = jsgraph()->Constant(language_mode());
1503 Node* position = jsgraph()->Constant(info()->scope()->start_position()); 1504 Node* position = jsgraph()->Constant(info()->scope()->start_position());
1504 const Operator* op = 1505 const Operator* op =
1505 javascript()->CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); 1506 javascript()->CallRuntime(Runtime::kResolvePossiblyDirectEval, 6);
1506 Node* pair = 1507 Node* pair =
1507 NewNode(op, callee, source, function, receiver, strict, position); 1508 NewNode(op, callee, source, function, receiver, language, position);
1508 PrepareFrameState(pair, expr->EvalOrLookupId(), 1509 PrepareFrameState(pair, expr->EvalOrLookupId(),
1509 OutputFrameStateCombine::PokeAt(arg_count + 1)); 1510 OutputFrameStateCombine::PokeAt(arg_count + 1));
1510 Node* new_callee = NewNode(common()->Projection(0), pair); 1511 Node* new_callee = NewNode(common()->Projection(0), pair);
1511 Node* new_receiver = NewNode(common()->Projection(1), pair); 1512 Node* new_receiver = NewNode(common()->Projection(1), pair);
1512 1513
1513 // Patch callee and receiver on the environment. 1514 // Patch callee and receiver on the environment.
1514 environment()->Poke(arg_count + 1, new_callee); 1515 environment()->Poke(arg_count + 1, new_callee);
1515 environment()->Poke(arg_count + 0, new_receiver); 1516 environment()->Poke(arg_count + 0, new_receiver);
1516 } 1517 }
1517 1518
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1680 environment()->Push(value); 1681 environment()->Push(value);
1681 BuildVariableAssignment(variable, value, expr->op(), 1682 BuildVariableAssignment(variable, value, expr->op(),
1682 expr->AssignmentId()); 1683 expr->AssignmentId());
1683 environment()->Pop(); 1684 environment()->Pop();
1684 break; 1685 break;
1685 } 1686 }
1686 case NAMED_PROPERTY: { 1687 case NAMED_PROPERTY: {
1687 Node* object = environment()->Pop(); 1688 Node* object = environment()->Pop();
1688 Unique<Name> name = 1689 Unique<Name> name =
1689 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); 1690 MakeUnique(property->key()->AsLiteral()->AsPropertyName());
1690 Node* store = 1691 Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
1691 NewNode(javascript()->StoreNamed(strict_mode(), name), object, value); 1692 object, value);
1692 environment()->Push(value); 1693 environment()->Push(value);
1693 PrepareFrameState(store, expr->AssignmentId()); 1694 PrepareFrameState(store, expr->AssignmentId());
1694 environment()->Pop(); 1695 environment()->Pop();
1695 break; 1696 break;
1696 } 1697 }
1697 case KEYED_PROPERTY: { 1698 case KEYED_PROPERTY: {
1698 Node* key = environment()->Pop(); 1699 Node* key = environment()->Pop();
1699 Node* object = environment()->Pop(); 1700 Node* object = environment()->Pop();
1700 Node* store = NewNode(javascript()->StoreProperty(strict_mode()), object, 1701 Node* store = NewNode(javascript()->StoreProperty(language_mode()),
1701 key, value); 1702 object, key, value);
1702 environment()->Push(value); 1703 environment()->Push(value);
1703 PrepareFrameState(store, expr->AssignmentId()); 1704 PrepareFrameState(store, expr->AssignmentId());
1704 environment()->Pop(); 1705 environment()->Pop();
1705 break; 1706 break;
1706 } 1707 }
1707 } 1708 }
1708 1709
1709 // Restore old value for postfix expressions. 1710 // Restore old value for postfix expressions.
1710 if (is_postfix) value = environment()->Pop(); 1711 if (is_postfix) value = environment()->Pop();
1711 1712
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 void AstGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) { 1800 void AstGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) {
1800 DCHECK(globals()->empty()); 1801 DCHECK(globals()->empty());
1801 AstVisitor::VisitDeclarations(declarations); 1802 AstVisitor::VisitDeclarations(declarations);
1802 if (globals()->empty()) return; 1803 if (globals()->empty()) return;
1803 int array_index = 0; 1804 int array_index = 0;
1804 Handle<FixedArray> data = isolate()->factory()->NewFixedArray( 1805 Handle<FixedArray> data = isolate()->factory()->NewFixedArray(
1805 static_cast<int>(globals()->size()), TENURED); 1806 static_cast<int>(globals()->size()), TENURED);
1806 for (Handle<Object> obj : *globals()) data->set(array_index++, *obj); 1807 for (Handle<Object> obj : *globals()) data->set(array_index++, *obj);
1807 int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) | 1808 int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) |
1808 DeclareGlobalsNativeFlag::encode(info()->is_native()) | 1809 DeclareGlobalsNativeFlag::encode(info()->is_native()) |
1809 DeclareGlobalsStrictMode::encode(strict_mode()); 1810 DeclareGlobalsLanguageMode::encode(language_mode());
1810 Node* flags = jsgraph()->Constant(encoded_flags); 1811 Node* flags = jsgraph()->Constant(encoded_flags);
1811 Node* pairs = jsgraph()->Constant(data); 1812 Node* pairs = jsgraph()->Constant(data);
1812 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals, 3); 1813 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals, 3);
1813 NewNode(op, current_context(), pairs, flags); 1814 NewNode(op, current_context(), pairs, flags);
1814 globals()->clear(); 1815 globals()->clear();
1815 } 1816 }
1816 1817
1817 1818
1818 void AstGraphBuilder::VisitIfNotNull(Statement* stmt) { 1819 void AstGraphBuilder::VisitIfNotNull(Statement* stmt) {
1819 if (stmt == NULL) return; 1820 if (stmt == NULL) return;
1820 Visit(stmt); 1821 Visit(stmt);
1821 } 1822 }
1822 1823
1823 1824
1824 void AstGraphBuilder::VisitIterationBody(IterationStatement* stmt, 1825 void AstGraphBuilder::VisitIterationBody(IterationStatement* stmt,
1825 LoopBuilder* loop, int drop_extra) { 1826 LoopBuilder* loop, int drop_extra) {
1826 BreakableScope scope(this, stmt, loop, drop_extra); 1827 BreakableScope scope(this, stmt, loop, drop_extra);
1827 Visit(stmt->body()); 1828 Visit(stmt->body());
1828 } 1829 }
1829 1830
1830 1831
1831 void AstGraphBuilder::VisitDelete(UnaryOperation* expr) { 1832 void AstGraphBuilder::VisitDelete(UnaryOperation* expr) {
1832 Node* value; 1833 Node* value;
1833 if (expr->expression()->IsVariableProxy()) { 1834 if (expr->expression()->IsVariableProxy()) {
1834 // Delete of an unqualified identifier is only allowed in classic mode but 1835 // Delete of an unqualified identifier is only allowed in classic mode but
1835 // deleting "this" is allowed in all language modes. 1836 // deleting "this" is allowed in all language modes.
1836 Variable* variable = expr->expression()->AsVariableProxy()->var(); 1837 Variable* variable = expr->expression()->AsVariableProxy()->var();
1837 DCHECK(strict_mode() == SLOPPY || variable->is_this()); 1838 DCHECK(!is_strict(language_mode()) || variable->is_this());
1838 value = BuildVariableDelete(variable, expr->id(), 1839 value = BuildVariableDelete(variable, expr->id(),
1839 ast_context()->GetStateCombine()); 1840 ast_context()->GetStateCombine());
1840 } else if (expr->expression()->IsProperty()) { 1841 } else if (expr->expression()->IsProperty()) {
1841 Property* property = expr->expression()->AsProperty(); 1842 Property* property = expr->expression()->AsProperty();
1842 VisitForValue(property->obj()); 1843 VisitForValue(property->obj());
1843 VisitForValue(property->key()); 1844 VisitForValue(property->key());
1844 Node* key = environment()->Pop(); 1845 Node* key = environment()->Pop();
1845 Node* object = environment()->Pop(); 1846 Node* object = environment()->Pop();
1846 value = NewNode(javascript()->DeleteProperty(strict_mode()), object, key); 1847 value = NewNode(javascript()->DeleteProperty(language_mode()), object, key);
1847 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 1848 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
1848 } else { 1849 } else {
1849 VisitForEffect(expr->expression()); 1850 VisitForEffect(expr->expression());
1850 value = jsgraph()->TrueConstant(); 1851 value = jsgraph()->TrueConstant();
1851 } 1852 }
1852 ast_context()->ProduceValue(value); 1853 ast_context()->ProduceValue(value);
1853 } 1854 }
1854 1855
1855 1856
1856 void AstGraphBuilder::VisitVoid(UnaryOperation* expr) { 1857 void AstGraphBuilder::VisitVoid(UnaryOperation* expr) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 environment()->Pop(); 1913 environment()->Pop();
1913 Visit(expr->right()); 1914 Visit(expr->right());
1914 } else if (ast_context()->IsEffect()) { 1915 } else if (ast_context()->IsEffect()) {
1915 environment()->Pop(); 1916 environment()->Pop();
1916 } 1917 }
1917 compare_if.End(); 1918 compare_if.End();
1918 ast_context()->ReplaceValue(); 1919 ast_context()->ReplaceValue();
1919 } 1920 }
1920 1921
1921 1922
1922 StrictMode AstGraphBuilder::strict_mode() const { 1923 LanguageMode AstGraphBuilder::language_mode() const {
1923 return info()->strict_mode(); 1924 return info()->language_mode();
1924 } 1925 }
1925 1926
1926 1927
1927 VectorSlotPair AstGraphBuilder::CreateVectorSlotPair( 1928 VectorSlotPair AstGraphBuilder::CreateVectorSlotPair(
1928 FeedbackVectorICSlot slot) const { 1929 FeedbackVectorICSlot slot) const {
1929 return VectorSlotPair(handle(info()->shared_info()->feedback_vector()), slot); 1930 return VectorSlotPair(handle(info()->shared_info()->feedback_vector()), slot);
1930 } 1931 }
1931 1932
1932 1933
1933 Node* AstGraphBuilder::ProcessArguments(const Operator* op, int arity) { 1934 Node* AstGraphBuilder::ProcessArguments(const Operator* op, int arity) {
1934 DCHECK(environment()->stack_height() >= arity); 1935 DCHECK(environment()->stack_height() >= arity);
1935 Node** all = info()->zone()->NewArray<Node*>(arity); 1936 Node** all = info()->zone()->NewArray<Node*>(arity);
1936 for (int i = arity - 1; i >= 0; --i) { 1937 for (int i = arity - 1; i >= 0; --i) {
1937 all[i] = environment()->Pop(); 1938 all[i] = environment()->Pop();
1938 } 1939 }
1939 Node* value = NewNode(op, arity, all); 1940 Node* value = NewNode(op, arity, all);
1940 return value; 1941 return value;
1941 } 1942 }
1942 1943
1943 1944
1944 Node* AstGraphBuilder::BuildPatchReceiverToGlobalProxy(Node* receiver) { 1945 Node* AstGraphBuilder::BuildPatchReceiverToGlobalProxy(Node* receiver) {
1945 // Sloppy mode functions and builtins need to replace the receiver with the 1946 // Sloppy mode functions and builtins need to replace the receiver with the
1946 // global proxy when called as functions (without an explicit receiver 1947 // global proxy when called as functions (without an explicit receiver
1947 // object). Otherwise there is nothing left to do here. 1948 // object). Otherwise there is nothing left to do here.
1948 if (info()->strict_mode() != SLOPPY || info()->is_native()) return receiver; 1949 if (is_strict(info()->language_mode()) || info()->is_native()) {
1950 return receiver;
1951 }
1949 1952
1950 // There is no need to perform patching if the receiver is never used. Note 1953 // There is no need to perform patching if the receiver is never used. Note
1951 // that scope predicates are purely syntactical, a call to eval might still 1954 // that scope predicates are purely syntactical, a call to eval might still
1952 // inspect the receiver value. 1955 // inspect the receiver value.
1953 if (!info()->scope()->uses_this() && !info()->scope()->inner_uses_this() && 1956 if (!info()->scope()->uses_this() && !info()->scope()->inner_uses_this() &&
1954 !info()->scope()->calls_sloppy_eval()) { 1957 !info()->scope()->calls_sloppy_eval()) {
1955 return receiver; 1958 return receiver;
1956 } 1959 }
1957 1960
1958 IfBuilder receiver_check(this); 1961 IfBuilder receiver_check(this);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 2136
2134 2137
2135 Node* AstGraphBuilder::BuildVariableDelete( 2138 Node* AstGraphBuilder::BuildVariableDelete(
2136 Variable* variable, BailoutId bailout_id, 2139 Variable* variable, BailoutId bailout_id,
2137 OutputFrameStateCombine state_combine) { 2140 OutputFrameStateCombine state_combine) {
2138 switch (variable->location()) { 2141 switch (variable->location()) {
2139 case Variable::UNALLOCATED: { 2142 case Variable::UNALLOCATED: {
2140 // Global var, const, or let variable. 2143 // Global var, const, or let variable.
2141 Node* global = BuildLoadGlobalObject(); 2144 Node* global = BuildLoadGlobalObject();
2142 Node* name = jsgraph()->Constant(variable->name()); 2145 Node* name = jsgraph()->Constant(variable->name());
2143 const Operator* op = javascript()->DeleteProperty(strict_mode()); 2146 const Operator* op = javascript()->DeleteProperty(language_mode());
2144 Node* result = NewNode(op, global, name); 2147 Node* result = NewNode(op, global, name);
2145 PrepareFrameState(result, bailout_id, state_combine); 2148 PrepareFrameState(result, bailout_id, state_combine);
2146 return result; 2149 return result;
2147 } 2150 }
2148 case Variable::PARAMETER: 2151 case Variable::PARAMETER:
2149 case Variable::LOCAL: 2152 case Variable::LOCAL:
2150 case Variable::CONTEXT: 2153 case Variable::CONTEXT:
2151 // Local var, const, or let variable or context variable. 2154 // Local var, const, or let variable or context variable.
2152 return jsgraph()->BooleanConstant(variable->is_this()); 2155 return jsgraph()->BooleanConstant(variable->is_this());
2153 case Variable::LOOKUP: { 2156 case Variable::LOOKUP: {
(...skipping 14 matching lines...) Expand all
2168 Node* AstGraphBuilder::BuildVariableAssignment( 2171 Node* AstGraphBuilder::BuildVariableAssignment(
2169 Variable* variable, Node* value, Token::Value op, BailoutId bailout_id, 2172 Variable* variable, Node* value, Token::Value op, BailoutId bailout_id,
2170 OutputFrameStateCombine combine) { 2173 OutputFrameStateCombine combine) {
2171 Node* the_hole = jsgraph()->TheHoleConstant(); 2174 Node* the_hole = jsgraph()->TheHoleConstant();
2172 VariableMode mode = variable->mode(); 2175 VariableMode mode = variable->mode();
2173 switch (variable->location()) { 2176 switch (variable->location()) {
2174 case Variable::UNALLOCATED: { 2177 case Variable::UNALLOCATED: {
2175 // Global var, const, or let variable. 2178 // Global var, const, or let variable.
2176 Node* global = BuildLoadGlobalObject(); 2179 Node* global = BuildLoadGlobalObject();
2177 Unique<Name> name = MakeUnique(variable->name()); 2180 Unique<Name> name = MakeUnique(variable->name());
2178 const Operator* op = javascript()->StoreNamed(strict_mode(), name); 2181 const Operator* op = javascript()->StoreNamed(language_mode(), name);
2179 Node* store = NewNode(op, global, value); 2182 Node* store = NewNode(op, global, value);
2180 PrepareFrameState(store, bailout_id, combine); 2183 PrepareFrameState(store, bailout_id, combine);
2181 return store; 2184 return store;
2182 } 2185 }
2183 case Variable::PARAMETER: 2186 case Variable::PARAMETER:
2184 case Variable::LOCAL: 2187 case Variable::LOCAL:
2185 // Local var, const, or let variable. 2188 // Local var, const, or let variable.
2186 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { 2189 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) {
2187 // Perform an initialization check for legacy const variables. 2190 // Perform an initialization check for legacy const variables.
2188 Node* current = environment()->Lookup(variable); 2191 Node* current = environment()->Lookup(variable);
2189 if (current->op() != the_hole->op()) { 2192 if (current->op() != the_hole->op()) {
2190 value = BuildHoleCheckSilent(current, value, current); 2193 value = BuildHoleCheckSilent(current, value, current);
2191 } 2194 }
2192 } else if (mode == CONST_LEGACY && op != Token::INIT_CONST_LEGACY) { 2195 } else if (mode == CONST_LEGACY && op != Token::INIT_CONST_LEGACY) {
2193 // Non-initializing assignments to legacy const is 2196 // Non-initializing assignments to legacy const is
2194 // - exception in strict mode. 2197 // - exception in strict mode.
2195 // - ignored in sloppy mode. 2198 // - ignored in sloppy mode.
2196 if (strict_mode() == STRICT) { 2199 if (is_strict(language_mode())) {
2197 return BuildThrowConstAssignError(bailout_id); 2200 return BuildThrowConstAssignError(bailout_id);
2198 } 2201 }
2199 return value; 2202 return value;
2200 } else if (mode == LET && op != Token::INIT_LET) { 2203 } else if (mode == LET && op != Token::INIT_LET) {
2201 // Perform an initialization check for let declared variables. 2204 // Perform an initialization check for let declared variables.
2202 // Also note that the dynamic hole-check is only done to ensure that 2205 // Also note that the dynamic hole-check is only done to ensure that
2203 // this does not break in the presence of do-expressions within the 2206 // this does not break in the presence of do-expressions within the
2204 // temporal dead zone of a let declared variable. 2207 // temporal dead zone of a let declared variable.
2205 Node* current = environment()->Lookup(variable); 2208 Node* current = environment()->Lookup(variable);
2206 if (current->op() == the_hole->op()) { 2209 if (current->op() == the_hole->op()) {
(...skipping 13 matching lines...) Expand all
2220 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { 2223 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) {
2221 // Perform an initialization check for legacy const variables. 2224 // Perform an initialization check for legacy const variables.
2222 const Operator* op = 2225 const Operator* op =
2223 javascript()->LoadContext(depth, variable->index(), false); 2226 javascript()->LoadContext(depth, variable->index(), false);
2224 Node* current = NewNode(op, current_context()); 2227 Node* current = NewNode(op, current_context());
2225 value = BuildHoleCheckSilent(current, value, current); 2228 value = BuildHoleCheckSilent(current, value, current);
2226 } else if (mode == CONST_LEGACY && op != Token::INIT_CONST_LEGACY) { 2229 } else if (mode == CONST_LEGACY && op != Token::INIT_CONST_LEGACY) {
2227 // Non-initializing assignments to legacy const is 2230 // Non-initializing assignments to legacy const is
2228 // - exception in strict mode. 2231 // - exception in strict mode.
2229 // - ignored in sloppy mode. 2232 // - ignored in sloppy mode.
2230 if (strict_mode() == STRICT) { 2233 if (is_strict(language_mode())) {
2231 return BuildThrowConstAssignError(bailout_id); 2234 return BuildThrowConstAssignError(bailout_id);
2232 } 2235 }
2233 return value; 2236 return value;
2234 } else if (mode == LET && op != Token::INIT_LET) { 2237 } else if (mode == LET && op != Token::INIT_LET) {
2235 // Perform an initialization check for let declared variables. 2238 // Perform an initialization check for let declared variables.
2236 const Operator* op = 2239 const Operator* op =
2237 javascript()->LoadContext(depth, variable->index(), false); 2240 javascript()->LoadContext(depth, variable->index(), false);
2238 Node* current = NewNode(op, current_context()); 2241 Node* current = NewNode(op, current_context());
2239 value = BuildHoleCheckThrow(current, variable, value, bailout_id); 2242 value = BuildHoleCheckThrow(current, variable, value, bailout_id);
2240 } else if (mode == CONST && op != Token::INIT_CONST) { 2243 } else if (mode == CONST && op != Token::INIT_CONST) {
2241 // Non-initializing assignments to const is exception in all modes. 2244 // Non-initializing assignments to const is exception in all modes.
2242 return BuildThrowConstAssignError(bailout_id); 2245 return BuildThrowConstAssignError(bailout_id);
2243 } 2246 }
2244 const Operator* op = javascript()->StoreContext(depth, variable->index()); 2247 const Operator* op = javascript()->StoreContext(depth, variable->index());
2245 return NewNode(op, current_context(), value); 2248 return NewNode(op, current_context(), value);
2246 } 2249 }
2247 case Variable::LOOKUP: { 2250 case Variable::LOOKUP: {
2248 // Dynamic lookup of context variable (anywhere in the chain). 2251 // Dynamic lookup of context variable (anywhere in the chain).
2249 Node* name = jsgraph()->Constant(variable->name()); 2252 Node* name = jsgraph()->Constant(variable->name());
2250 Node* strict = jsgraph()->Constant(strict_mode()); 2253 Node* language = jsgraph()->Constant(language_mode());
2251 // TODO(mstarzinger): Use Runtime::kInitializeLegacyConstLookupSlot for 2254 // TODO(mstarzinger): Use Runtime::kInitializeLegacyConstLookupSlot for
2252 // initializations of const declarations. 2255 // initializations of const declarations.
2253 const Operator* op = 2256 const Operator* op =
2254 javascript()->CallRuntime(Runtime::kStoreLookupSlot, 4); 2257 javascript()->CallRuntime(Runtime::kStoreLookupSlot, 4);
2255 Node* store = NewNode(op, value, current_context(), name, strict); 2258 Node* store = NewNode(op, value, current_context(), name, language);
2256 PrepareFrameState(store, bailout_id, combine); 2259 PrepareFrameState(store, bailout_id, combine);
2257 return store; 2260 return store;
2258 } 2261 }
2259 } 2262 }
2260 UNREACHABLE(); 2263 UNREACHABLE();
2261 return NULL; 2264 return NULL;
2262 } 2265 }
2263 2266
2264 2267
2265 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { 2268 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2435 2438
2436 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop( 2439 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop(
2437 IterationStatement* stmt) { 2440 IterationStatement* stmt) {
2438 if (loop_assignment_analysis_ == NULL) return NULL; 2441 if (loop_assignment_analysis_ == NULL) return NULL;
2439 return loop_assignment_analysis_->GetVariablesAssignedInLoop(stmt); 2442 return loop_assignment_analysis_->GetVariablesAssignedInLoop(stmt);
2440 } 2443 }
2441 2444
2442 } // namespace compiler 2445 } // namespace compiler
2443 } // namespace internal 2446 } // namespace internal
2444 } // namespace v8 2447 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698