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

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: rebased (w/ conflicts) 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
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 NewNode(op, receiver, key, value); 1350 NewNode(op, receiver, key, value);
1351 break; 1351 break;
1352 } 1352 }
1353 } 1353 }
1354 1354
1355 // TODO(mstarzinger): This is temporary to make "super" work and replicates 1355 // TODO(mstarzinger): This is temporary to make "super" work and replicates
1356 // the existing FullCodeGenerator::NeedsHomeObject predicate. 1356 // the existing FullCodeGenerator::NeedsHomeObject predicate.
1357 if (FunctionLiteral::NeedsHomeObject(property->value())) { 1357 if (FunctionLiteral::NeedsHomeObject(property->value())) {
1358 Unique<Name> name = 1358 Unique<Name> name =
1359 MakeUnique(isolate()->factory()->home_object_symbol()); 1359 MakeUnique(isolate()->factory()->home_object_symbol());
1360 Node* store = NewNode(javascript()->StoreNamed(strict_mode(), name), 1360 Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
1361 value, receiver); 1361 value, receiver);
1362 PrepareFrameState(store, BailoutId::None()); 1362 PrepareFrameState(store, BailoutId::None());
1363 } 1363 }
1364 } 1364 }
1365 1365
1366 // Transform both the class literal and the prototype to fast properties. 1366 // Transform both the class literal and the prototype to fast properties.
1367 const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties, 1); 1367 const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties, 1);
1368 NewNode(op, environment()->Pop()); // prototype 1368 NewNode(op, environment()->Pop()); // prototype
1369 NewNode(op, environment()->Pop()); // literal 1369 NewNode(op, environment()->Pop()); // literal
1370 1370
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); 1470 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value()));
1471 // Fall through. 1471 // Fall through.
1472 case ObjectLiteral::Property::COMPUTED: { 1472 case ObjectLiteral::Property::COMPUTED: {
1473 // It is safe to use [[Put]] here because the boilerplate already 1473 // It is safe to use [[Put]] here because the boilerplate already
1474 // contains computed properties with an uninitialized value. 1474 // contains computed properties with an uninitialized value.
1475 if (key->value()->IsInternalizedString()) { 1475 if (key->value()->IsInternalizedString()) {
1476 if (property->emit_store()) { 1476 if (property->emit_store()) {
1477 VisitForValue(property->value()); 1477 VisitForValue(property->value());
1478 Node* value = environment()->Pop(); 1478 Node* value = environment()->Pop();
1479 Unique<Name> name = MakeUnique(key->AsPropertyName()); 1479 Unique<Name> name = MakeUnique(key->AsPropertyName());
1480 Node* store = NewNode(javascript()->StoreNamed(strict_mode(), name), 1480 Node* store =
1481 literal, value); 1481 NewNode(javascript()->StoreNamed(language_mode(), name),
1482 literal, value);
1482 PrepareFrameState(store, key->id()); 1483 PrepareFrameState(store, key->id());
1483 } else { 1484 } else {
1484 VisitForEffect(property->value()); 1485 VisitForEffect(property->value());
1485 } 1486 }
1486 break; 1487 break;
1487 } 1488 }
1488 environment()->Push(literal); // Duplicate receiver. 1489 environment()->Push(literal); // Duplicate receiver.
1489 VisitForValue(property->key()); 1490 VisitForValue(property->key());
1490 VisitForValue(property->value()); 1491 VisitForValue(property->value());
1491 Node* value = environment()->Pop(); 1492 Node* value = environment()->Pop();
1492 Node* key = environment()->Pop(); 1493 Node* key = environment()->Pop();
1493 Node* receiver = environment()->Pop(); 1494 Node* receiver = environment()->Pop();
1494 if (property->emit_store()) { 1495 if (property->emit_store()) {
1495 Node* strict = jsgraph()->Constant(SLOPPY); 1496 Node* language = jsgraph()->Constant(SLOPPY);
1496 const Operator* op = 1497 const Operator* op =
1497 javascript()->CallRuntime(Runtime::kSetProperty, 4); 1498 javascript()->CallRuntime(Runtime::kSetProperty, 4);
1498 NewNode(op, receiver, key, value, strict); 1499 NewNode(op, receiver, key, value, language);
1499 } 1500 }
1500 break; 1501 break;
1501 } 1502 }
1502 case ObjectLiteral::Property::PROTOTYPE: { 1503 case ObjectLiteral::Property::PROTOTYPE: {
1503 environment()->Push(literal); // Duplicate receiver. 1504 environment()->Push(literal); // Duplicate receiver.
1504 VisitForValue(property->value()); 1505 VisitForValue(property->value());
1505 Node* value = environment()->Pop(); 1506 Node* value = environment()->Pop();
1506 Node* receiver = environment()->Pop(); 1507 Node* receiver = environment()->Pop();
1507 DCHECK(property->emit_store()); 1508 DCHECK(property->emit_store());
1508 const Operator* op = 1509 const Operator* op =
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 1633
1633 // Create nodes to evaluate all the non-constant subexpressions and to store 1634 // Create nodes to evaluate all the non-constant subexpressions and to store
1634 // them into the newly cloned array. 1635 // them into the newly cloned array.
1635 for (int i = 0; i < expr->values()->length(); i++) { 1636 for (int i = 0; i < expr->values()->length(); i++) {
1636 Expression* subexpr = expr->values()->at(i); 1637 Expression* subexpr = expr->values()->at(i);
1637 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1638 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1638 1639
1639 VisitForValue(subexpr); 1640 VisitForValue(subexpr);
1640 Node* value = environment()->Pop(); 1641 Node* value = environment()->Pop();
1641 Node* index = jsgraph()->Constant(i); 1642 Node* index = jsgraph()->Constant(i);
1642 Node* store = NewNode(javascript()->StoreProperty(strict_mode()), literal, 1643 Node* store = NewNode(javascript()->StoreProperty(language_mode()), literal,
1643 index, value); 1644 index, value);
1644 PrepareFrameState(store, expr->GetIdForElement(i)); 1645 PrepareFrameState(store, expr->GetIdForElement(i));
1645 } 1646 }
1646 1647
1647 environment()->Pop(); // Array literal index. 1648 environment()->Pop(); // Array literal index.
1648 ast_context()->ProduceValue(environment()->Pop()); 1649 ast_context()->ProduceValue(environment()->Pop());
1649 } 1650 }
1650 1651
1651 1652
1652 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value, 1653 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value,
(...skipping 11 matching lines...) Expand all
1664 BuildVariableAssignment(var, value, Token::ASSIGN, bailout_id); 1665 BuildVariableAssignment(var, value, Token::ASSIGN, bailout_id);
1665 break; 1666 break;
1666 } 1667 }
1667 case NAMED_PROPERTY: { 1668 case NAMED_PROPERTY: {
1668 environment()->Push(value); 1669 environment()->Push(value);
1669 VisitForValue(property->obj()); 1670 VisitForValue(property->obj());
1670 Node* object = environment()->Pop(); 1671 Node* object = environment()->Pop();
1671 value = environment()->Pop(); 1672 value = environment()->Pop();
1672 Unique<Name> name = 1673 Unique<Name> name =
1673 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); 1674 MakeUnique(property->key()->AsLiteral()->AsPropertyName());
1674 Node* store = 1675 Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
1675 NewNode(javascript()->StoreNamed(strict_mode(), name), object, value); 1676 object, value);
1676 PrepareFrameState(store, bailout_id); 1677 PrepareFrameState(store, bailout_id);
1677 break; 1678 break;
1678 } 1679 }
1679 case KEYED_PROPERTY: { 1680 case KEYED_PROPERTY: {
1680 environment()->Push(value); 1681 environment()->Push(value);
1681 VisitForValue(property->obj()); 1682 VisitForValue(property->obj());
1682 VisitForValue(property->key()); 1683 VisitForValue(property->key());
1683 Node* key = environment()->Pop(); 1684 Node* key = environment()->Pop();
1684 Node* object = environment()->Pop(); 1685 Node* object = environment()->Pop();
1685 value = environment()->Pop(); 1686 value = environment()->Pop();
1686 Node* store = NewNode(javascript()->StoreProperty(strict_mode()), object, 1687 Node* store = NewNode(javascript()->StoreProperty(language_mode()),
1687 key, value); 1688 object, key, value);
1688 PrepareFrameState(store, bailout_id); 1689 PrepareFrameState(store, bailout_id);
1689 break; 1690 break;
1690 } 1691 }
1691 } 1692 }
1692 } 1693 }
1693 1694
1694 1695
1695 void AstGraphBuilder::VisitAssignment(Assignment* expr) { 1696 void AstGraphBuilder::VisitAssignment(Assignment* expr) {
1696 DCHECK(expr->target()->IsValidReferenceExpression()); 1697 DCHECK(expr->target()->IsValidReferenceExpression());
1697 1698
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1766 case VARIABLE: { 1767 case VARIABLE: {
1767 Variable* variable = expr->target()->AsVariableProxy()->var(); 1768 Variable* variable = expr->target()->AsVariableProxy()->var();
1768 BuildVariableAssignment(variable, value, expr->op(), expr->AssignmentId(), 1769 BuildVariableAssignment(variable, value, expr->op(), expr->AssignmentId(),
1769 ast_context()->GetStateCombine()); 1770 ast_context()->GetStateCombine());
1770 break; 1771 break;
1771 } 1772 }
1772 case NAMED_PROPERTY: { 1773 case NAMED_PROPERTY: {
1773 Node* object = environment()->Pop(); 1774 Node* object = environment()->Pop();
1774 Unique<Name> name = 1775 Unique<Name> name =
1775 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); 1776 MakeUnique(property->key()->AsLiteral()->AsPropertyName());
1776 Node* store = 1777 Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
1777 NewNode(javascript()->StoreNamed(strict_mode(), name), object, value); 1778 object, value);
1778 PrepareFrameState(store, expr->AssignmentId(), 1779 PrepareFrameState(store, expr->AssignmentId(),
1779 ast_context()->GetStateCombine()); 1780 ast_context()->GetStateCombine());
1780 break; 1781 break;
1781 } 1782 }
1782 case KEYED_PROPERTY: { 1783 case KEYED_PROPERTY: {
1783 Node* key = environment()->Pop(); 1784 Node* key = environment()->Pop();
1784 Node* object = environment()->Pop(); 1785 Node* object = environment()->Pop();
1785 Node* store = NewNode(javascript()->StoreProperty(strict_mode()), object, 1786 Node* store = NewNode(javascript()->StoreProperty(language_mode()),
1786 key, value); 1787 object, key, value);
1787 PrepareFrameState(store, expr->AssignmentId(), 1788 PrepareFrameState(store, expr->AssignmentId(),
1788 ast_context()->GetStateCombine()); 1789 ast_context()->GetStateCombine());
1789 break; 1790 break;
1790 } 1791 }
1791 } 1792 }
1792 1793
1793 ast_context()->ProduceValue(value); 1794 ast_context()->ProduceValue(value);
1794 } 1795 }
1795 1796
1796 1797
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 int arg_count = args->length(); 1926 int arg_count = args->length();
1926 1927
1927 // Extract callee and source string from the environment. 1928 // Extract callee and source string from the environment.
1928 Node* callee = environment()->Peek(arg_count + 1); 1929 Node* callee = environment()->Peek(arg_count + 1);
1929 Node* source = environment()->Peek(arg_count - 1); 1930 Node* source = environment()->Peek(arg_count - 1);
1930 1931
1931 // Create node to ask for help resolving potential eval call. This will 1932 // Create node to ask for help resolving potential eval call. This will
1932 // provide a fully resolved callee and the corresponding receiver. 1933 // provide a fully resolved callee and the corresponding receiver.
1933 Node* function = GetFunctionClosure(); 1934 Node* function = GetFunctionClosure();
1934 Node* receiver = environment()->Lookup(info()->scope()->receiver()); 1935 Node* receiver = environment()->Lookup(info()->scope()->receiver());
1935 Node* strict = jsgraph()->Constant(strict_mode()); 1936 Node* language = jsgraph()->Constant(language_mode());
1936 Node* position = jsgraph()->Constant(info()->scope()->start_position()); 1937 Node* position = jsgraph()->Constant(info()->scope()->start_position());
1937 const Operator* op = 1938 const Operator* op =
1938 javascript()->CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); 1939 javascript()->CallRuntime(Runtime::kResolvePossiblyDirectEval, 6);
1939 Node* pair = 1940 Node* pair =
1940 NewNode(op, callee, source, function, receiver, strict, position); 1941 NewNode(op, callee, source, function, receiver, language, position);
1941 PrepareFrameState(pair, expr->EvalOrLookupId(), 1942 PrepareFrameState(pair, expr->EvalOrLookupId(),
1942 OutputFrameStateCombine::PokeAt(arg_count + 1)); 1943 OutputFrameStateCombine::PokeAt(arg_count + 1));
1943 Node* new_callee = NewNode(common()->Projection(0), pair); 1944 Node* new_callee = NewNode(common()->Projection(0), pair);
1944 Node* new_receiver = NewNode(common()->Projection(1), pair); 1945 Node* new_receiver = NewNode(common()->Projection(1), pair);
1945 1946
1946 // Patch callee and receiver on the environment. 1947 // Patch callee and receiver on the environment.
1947 environment()->Poke(arg_count + 1, new_callee); 1948 environment()->Poke(arg_count + 1, new_callee);
1948 environment()->Poke(arg_count + 0, new_receiver); 1949 environment()->Poke(arg_count + 0, new_receiver);
1949 } 1950 }
1950 1951
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2113 environment()->Push(value); 2114 environment()->Push(value);
2114 BuildVariableAssignment(variable, value, expr->op(), 2115 BuildVariableAssignment(variable, value, expr->op(),
2115 expr->AssignmentId()); 2116 expr->AssignmentId());
2116 environment()->Pop(); 2117 environment()->Pop();
2117 break; 2118 break;
2118 } 2119 }
2119 case NAMED_PROPERTY: { 2120 case NAMED_PROPERTY: {
2120 Node* object = environment()->Pop(); 2121 Node* object = environment()->Pop();
2121 Unique<Name> name = 2122 Unique<Name> name =
2122 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); 2123 MakeUnique(property->key()->AsLiteral()->AsPropertyName());
2123 Node* store = 2124 Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
2124 NewNode(javascript()->StoreNamed(strict_mode(), name), object, value); 2125 object, value);
2125 environment()->Push(value); 2126 environment()->Push(value);
2126 PrepareFrameState(store, expr->AssignmentId()); 2127 PrepareFrameState(store, expr->AssignmentId());
2127 environment()->Pop(); 2128 environment()->Pop();
2128 break; 2129 break;
2129 } 2130 }
2130 case KEYED_PROPERTY: { 2131 case KEYED_PROPERTY: {
2131 Node* key = environment()->Pop(); 2132 Node* key = environment()->Pop();
2132 Node* object = environment()->Pop(); 2133 Node* object = environment()->Pop();
2133 Node* store = NewNode(javascript()->StoreProperty(strict_mode()), object, 2134 Node* store = NewNode(javascript()->StoreProperty(language_mode()),
2134 key, value); 2135 object, key, value);
2135 environment()->Push(value); 2136 environment()->Push(value);
2136 PrepareFrameState(store, expr->AssignmentId()); 2137 PrepareFrameState(store, expr->AssignmentId());
2137 environment()->Pop(); 2138 environment()->Pop();
2138 break; 2139 break;
2139 } 2140 }
2140 } 2141 }
2141 2142
2142 // Restore old value for postfix expressions. 2143 // Restore old value for postfix expressions.
2143 if (is_postfix) value = environment()->Pop(); 2144 if (is_postfix) value = environment()->Pop();
2144 2145
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 void AstGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) { 2233 void AstGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) {
2233 DCHECK(globals()->empty()); 2234 DCHECK(globals()->empty());
2234 AstVisitor::VisitDeclarations(declarations); 2235 AstVisitor::VisitDeclarations(declarations);
2235 if (globals()->empty()) return; 2236 if (globals()->empty()) return;
2236 int array_index = 0; 2237 int array_index = 0;
2237 Handle<FixedArray> data = isolate()->factory()->NewFixedArray( 2238 Handle<FixedArray> data = isolate()->factory()->NewFixedArray(
2238 static_cast<int>(globals()->size()), TENURED); 2239 static_cast<int>(globals()->size()), TENURED);
2239 for (Handle<Object> obj : *globals()) data->set(array_index++, *obj); 2240 for (Handle<Object> obj : *globals()) data->set(array_index++, *obj);
2240 int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) | 2241 int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) |
2241 DeclareGlobalsNativeFlag::encode(info()->is_native()) | 2242 DeclareGlobalsNativeFlag::encode(info()->is_native()) |
2242 DeclareGlobalsStrictMode::encode(strict_mode()); 2243 DeclareGlobalsLanguageMode::encode(language_mode());
2243 Node* flags = jsgraph()->Constant(encoded_flags); 2244 Node* flags = jsgraph()->Constant(encoded_flags);
2244 Node* pairs = jsgraph()->Constant(data); 2245 Node* pairs = jsgraph()->Constant(data);
2245 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals, 3); 2246 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals, 3);
2246 NewNode(op, current_context(), pairs, flags); 2247 NewNode(op, current_context(), pairs, flags);
2247 globals()->clear(); 2248 globals()->clear();
2248 } 2249 }
2249 2250
2250 2251
2251 void AstGraphBuilder::VisitIfNotNull(Statement* stmt) { 2252 void AstGraphBuilder::VisitIfNotNull(Statement* stmt) {
2252 if (stmt == NULL) return; 2253 if (stmt == NULL) return;
2253 Visit(stmt); 2254 Visit(stmt);
2254 } 2255 }
2255 2256
2256 2257
2257 void AstGraphBuilder::VisitIterationBody(IterationStatement* stmt, 2258 void AstGraphBuilder::VisitIterationBody(IterationStatement* stmt,
2258 LoopBuilder* loop, int stack_delta) { 2259 LoopBuilder* loop, int stack_delta) {
2259 ControlScopeForIteration scope(this, stmt, loop, stack_delta); 2260 ControlScopeForIteration scope(this, stmt, loop, stack_delta);
2260 Visit(stmt->body()); 2261 Visit(stmt->body());
2261 } 2262 }
2262 2263
2263 2264
2264 void AstGraphBuilder::VisitDelete(UnaryOperation* expr) { 2265 void AstGraphBuilder::VisitDelete(UnaryOperation* expr) {
2265 Node* value; 2266 Node* value;
2266 if (expr->expression()->IsVariableProxy()) { 2267 if (expr->expression()->IsVariableProxy()) {
2267 // Delete of an unqualified identifier is only allowed in classic mode but 2268 // Delete of an unqualified identifier is only allowed in classic mode but
2268 // deleting "this" is allowed in all language modes. 2269 // deleting "this" is allowed in all language modes.
2269 Variable* variable = expr->expression()->AsVariableProxy()->var(); 2270 Variable* variable = expr->expression()->AsVariableProxy()->var();
2270 DCHECK(strict_mode() == SLOPPY || variable->is_this()); 2271 DCHECK(is_sloppy(language_mode()) || variable->is_this());
2271 value = BuildVariableDelete(variable, expr->id(), 2272 value = BuildVariableDelete(variable, expr->id(),
2272 ast_context()->GetStateCombine()); 2273 ast_context()->GetStateCombine());
2273 } else if (expr->expression()->IsProperty()) { 2274 } else if (expr->expression()->IsProperty()) {
2274 Property* property = expr->expression()->AsProperty(); 2275 Property* property = expr->expression()->AsProperty();
2275 VisitForValue(property->obj()); 2276 VisitForValue(property->obj());
2276 VisitForValue(property->key()); 2277 VisitForValue(property->key());
2277 Node* key = environment()->Pop(); 2278 Node* key = environment()->Pop();
2278 Node* object = environment()->Pop(); 2279 Node* object = environment()->Pop();
2279 value = NewNode(javascript()->DeleteProperty(strict_mode()), object, key); 2280 value = NewNode(javascript()->DeleteProperty(language_mode()), object, key);
2280 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 2281 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
2281 } else { 2282 } else {
2282 VisitForEffect(expr->expression()); 2283 VisitForEffect(expr->expression());
2283 value = jsgraph()->TrueConstant(); 2284 value = jsgraph()->TrueConstant();
2284 } 2285 }
2285 ast_context()->ProduceValue(value); 2286 ast_context()->ProduceValue(value);
2286 } 2287 }
2287 2288
2288 2289
2289 void AstGraphBuilder::VisitVoid(UnaryOperation* expr) { 2290 void AstGraphBuilder::VisitVoid(UnaryOperation* expr) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 environment()->Pop(); 2346 environment()->Pop();
2346 Visit(expr->right()); 2347 Visit(expr->right());
2347 } else if (ast_context()->IsEffect()) { 2348 } else if (ast_context()->IsEffect()) {
2348 environment()->Pop(); 2349 environment()->Pop();
2349 } 2350 }
2350 compare_if.End(); 2351 compare_if.End();
2351 ast_context()->ReplaceValue(); 2352 ast_context()->ReplaceValue();
2352 } 2353 }
2353 2354
2354 2355
2355 StrictMode AstGraphBuilder::strict_mode() const { 2356 LanguageMode AstGraphBuilder::language_mode() const {
2356 return info()->strict_mode(); 2357 return info()->language_mode();
2357 } 2358 }
2358 2359
2359 2360
2360 VectorSlotPair AstGraphBuilder::CreateVectorSlotPair( 2361 VectorSlotPair AstGraphBuilder::CreateVectorSlotPair(
2361 FeedbackVectorICSlot slot) const { 2362 FeedbackVectorICSlot slot) const {
2362 return VectorSlotPair(handle(info()->shared_info()->feedback_vector()), slot); 2363 return VectorSlotPair(handle(info()->shared_info()->feedback_vector()), slot);
2363 } 2364 }
2364 2365
2365 2366
2366 Node* AstGraphBuilder::ProcessArguments(const Operator* op, int arity) { 2367 Node* AstGraphBuilder::ProcessArguments(const Operator* op, int arity) {
2367 DCHECK(environment()->stack_height() >= arity); 2368 DCHECK(environment()->stack_height() >= arity);
2368 Node** all = info()->zone()->NewArray<Node*>(arity); 2369 Node** all = info()->zone()->NewArray<Node*>(arity);
2369 for (int i = arity - 1; i >= 0; --i) { 2370 for (int i = arity - 1; i >= 0; --i) {
2370 all[i] = environment()->Pop(); 2371 all[i] = environment()->Pop();
2371 } 2372 }
2372 Node* value = NewNode(op, arity, all); 2373 Node* value = NewNode(op, arity, all);
2373 return value; 2374 return value;
2374 } 2375 }
2375 2376
2376 2377
2377 Node* AstGraphBuilder::BuildPatchReceiverToGlobalProxy(Node* receiver) { 2378 Node* AstGraphBuilder::BuildPatchReceiverToGlobalProxy(Node* receiver) {
2378 // Sloppy mode functions and builtins need to replace the receiver with the 2379 // Sloppy mode functions and builtins need to replace the receiver with the
2379 // global proxy when called as functions (without an explicit receiver 2380 // global proxy when called as functions (without an explicit receiver
2380 // object). Otherwise there is nothing left to do here. 2381 // object). Otherwise there is nothing left to do here.
2381 if (strict_mode() != SLOPPY || info()->is_native()) return receiver; 2382 if (is_strict(language_mode()) || info()->is_native()) return receiver;
2382 2383
2383 // There is no need to perform patching if the receiver is never used. Note 2384 // There is no need to perform patching if the receiver is never used. Note
2384 // that scope predicates are purely syntactical, a call to eval might still 2385 // that scope predicates are purely syntactical, a call to eval might still
2385 // inspect the receiver value. 2386 // inspect the receiver value.
2386 if (!info()->scope()->uses_this() && !info()->scope()->inner_uses_this() && 2387 if (!info()->scope()->uses_this() && !info()->scope()->inner_uses_this() &&
2387 !info()->scope()->calls_sloppy_eval()) { 2388 !info()->scope()->calls_sloppy_eval()) {
2388 return receiver; 2389 return receiver;
2389 } 2390 }
2390 2391
2391 IfBuilder receiver_check(this); 2392 IfBuilder receiver_check(this);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 2567
2567 2568
2568 Node* AstGraphBuilder::BuildVariableDelete( 2569 Node* AstGraphBuilder::BuildVariableDelete(
2569 Variable* variable, BailoutId bailout_id, 2570 Variable* variable, BailoutId bailout_id,
2570 OutputFrameStateCombine state_combine) { 2571 OutputFrameStateCombine state_combine) {
2571 switch (variable->location()) { 2572 switch (variable->location()) {
2572 case Variable::UNALLOCATED: { 2573 case Variable::UNALLOCATED: {
2573 // Global var, const, or let variable. 2574 // Global var, const, or let variable.
2574 Node* global = BuildLoadGlobalObject(); 2575 Node* global = BuildLoadGlobalObject();
2575 Node* name = jsgraph()->Constant(variable->name()); 2576 Node* name = jsgraph()->Constant(variable->name());
2576 const Operator* op = javascript()->DeleteProperty(strict_mode()); 2577 const Operator* op = javascript()->DeleteProperty(language_mode());
2577 Node* result = NewNode(op, global, name); 2578 Node* result = NewNode(op, global, name);
2578 PrepareFrameState(result, bailout_id, state_combine); 2579 PrepareFrameState(result, bailout_id, state_combine);
2579 return result; 2580 return result;
2580 } 2581 }
2581 case Variable::PARAMETER: 2582 case Variable::PARAMETER:
2582 case Variable::LOCAL: 2583 case Variable::LOCAL:
2583 case Variable::CONTEXT: 2584 case Variable::CONTEXT:
2584 // Local var, const, or let variable or context variable. 2585 // Local var, const, or let variable or context variable.
2585 return jsgraph()->BooleanConstant(variable->is_this()); 2586 return jsgraph()->BooleanConstant(variable->is_this());
2586 case Variable::LOOKUP: { 2587 case Variable::LOOKUP: {
(...skipping 14 matching lines...) Expand all
2601 Node* AstGraphBuilder::BuildVariableAssignment( 2602 Node* AstGraphBuilder::BuildVariableAssignment(
2602 Variable* variable, Node* value, Token::Value op, BailoutId bailout_id, 2603 Variable* variable, Node* value, Token::Value op, BailoutId bailout_id,
2603 OutputFrameStateCombine combine) { 2604 OutputFrameStateCombine combine) {
2604 Node* the_hole = jsgraph()->TheHoleConstant(); 2605 Node* the_hole = jsgraph()->TheHoleConstant();
2605 VariableMode mode = variable->mode(); 2606 VariableMode mode = variable->mode();
2606 switch (variable->location()) { 2607 switch (variable->location()) {
2607 case Variable::UNALLOCATED: { 2608 case Variable::UNALLOCATED: {
2608 // Global var, const, or let variable. 2609 // Global var, const, or let variable.
2609 Node* global = BuildLoadGlobalObject(); 2610 Node* global = BuildLoadGlobalObject();
2610 Unique<Name> name = MakeUnique(variable->name()); 2611 Unique<Name> name = MakeUnique(variable->name());
2611 const Operator* op = javascript()->StoreNamed(strict_mode(), name); 2612 const Operator* op = javascript()->StoreNamed(language_mode(), name);
2612 Node* store = NewNode(op, global, value); 2613 Node* store = NewNode(op, global, value);
2613 PrepareFrameState(store, bailout_id, combine); 2614 PrepareFrameState(store, bailout_id, combine);
2614 return store; 2615 return store;
2615 } 2616 }
2616 case Variable::PARAMETER: 2617 case Variable::PARAMETER:
2617 case Variable::LOCAL: 2618 case Variable::LOCAL:
2618 // Local var, const, or let variable. 2619 // Local var, const, or let variable.
2619 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { 2620 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) {
2620 // Perform an initialization check for legacy const variables. 2621 // Perform an initialization check for legacy const variables.
2621 Node* current = environment()->Lookup(variable); 2622 Node* current = environment()->Lookup(variable);
2622 if (current->op() != the_hole->op()) { 2623 if (current->op() != the_hole->op()) {
2623 value = BuildHoleCheckSilent(current, value, current); 2624 value = BuildHoleCheckSilent(current, value, current);
2624 } 2625 }
2625 } else if (mode == CONST_LEGACY && op != Token::INIT_CONST_LEGACY) { 2626 } else if (mode == CONST_LEGACY && op != Token::INIT_CONST_LEGACY) {
2626 // Non-initializing assignments to legacy const is 2627 // Non-initializing assignments to legacy const is
2627 // - exception in strict mode. 2628 // - exception in strict mode.
2628 // - ignored in sloppy mode. 2629 // - ignored in sloppy mode.
2629 if (strict_mode() == STRICT) { 2630 if (is_strict(language_mode())) {
2630 return BuildThrowConstAssignError(bailout_id); 2631 return BuildThrowConstAssignError(bailout_id);
2631 } 2632 }
2632 return value; 2633 return value;
2633 } else if (mode == LET && op != Token::INIT_LET) { 2634 } else if (mode == LET && op != Token::INIT_LET) {
2634 // Perform an initialization check for let declared variables. 2635 // Perform an initialization check for let declared variables.
2635 // Also note that the dynamic hole-check is only done to ensure that 2636 // Also note that the dynamic hole-check is only done to ensure that
2636 // this does not break in the presence of do-expressions within the 2637 // this does not break in the presence of do-expressions within the
2637 // temporal dead zone of a let declared variable. 2638 // temporal dead zone of a let declared variable.
2638 Node* current = environment()->Lookup(variable); 2639 Node* current = environment()->Lookup(variable);
2639 if (current->op() == the_hole->op()) { 2640 if (current->op() == the_hole->op()) {
(...skipping 13 matching lines...) Expand all
2653 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { 2654 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) {
2654 // Perform an initialization check for legacy const variables. 2655 // Perform an initialization check for legacy const variables.
2655 const Operator* op = 2656 const Operator* op =
2656 javascript()->LoadContext(depth, variable->index(), false); 2657 javascript()->LoadContext(depth, variable->index(), false);
2657 Node* current = NewNode(op, current_context()); 2658 Node* current = NewNode(op, current_context());
2658 value = BuildHoleCheckSilent(current, value, current); 2659 value = BuildHoleCheckSilent(current, value, current);
2659 } else if (mode == CONST_LEGACY && op != Token::INIT_CONST_LEGACY) { 2660 } else if (mode == CONST_LEGACY && op != Token::INIT_CONST_LEGACY) {
2660 // Non-initializing assignments to legacy const is 2661 // Non-initializing assignments to legacy const is
2661 // - exception in strict mode. 2662 // - exception in strict mode.
2662 // - ignored in sloppy mode. 2663 // - ignored in sloppy mode.
2663 if (strict_mode() == STRICT) { 2664 if (is_strict(language_mode())) {
2664 return BuildThrowConstAssignError(bailout_id); 2665 return BuildThrowConstAssignError(bailout_id);
2665 } 2666 }
2666 return value; 2667 return value;
2667 } else if (mode == LET && op != Token::INIT_LET) { 2668 } else if (mode == LET && op != Token::INIT_LET) {
2668 // Perform an initialization check for let declared variables. 2669 // Perform an initialization check for let declared variables.
2669 const Operator* op = 2670 const Operator* op =
2670 javascript()->LoadContext(depth, variable->index(), false); 2671 javascript()->LoadContext(depth, variable->index(), false);
2671 Node* current = NewNode(op, current_context()); 2672 Node* current = NewNode(op, current_context());
2672 value = BuildHoleCheckThrow(current, variable, value, bailout_id); 2673 value = BuildHoleCheckThrow(current, variable, value, bailout_id);
2673 } else if (mode == CONST && op != Token::INIT_CONST) { 2674 } else if (mode == CONST && op != Token::INIT_CONST) {
2674 // Non-initializing assignments to const is exception in all modes. 2675 // Non-initializing assignments to const is exception in all modes.
2675 return BuildThrowConstAssignError(bailout_id); 2676 return BuildThrowConstAssignError(bailout_id);
2676 } 2677 }
2677 const Operator* op = javascript()->StoreContext(depth, variable->index()); 2678 const Operator* op = javascript()->StoreContext(depth, variable->index());
2678 return NewNode(op, current_context(), value); 2679 return NewNode(op, current_context(), value);
2679 } 2680 }
2680 case Variable::LOOKUP: { 2681 case Variable::LOOKUP: {
2681 // Dynamic lookup of context variable (anywhere in the chain). 2682 // Dynamic lookup of context variable (anywhere in the chain).
2682 Node* name = jsgraph()->Constant(variable->name()); 2683 Node* name = jsgraph()->Constant(variable->name());
2683 Node* strict = jsgraph()->Constant(strict_mode()); 2684 Node* language = jsgraph()->Constant(language_mode());
2684 // TODO(mstarzinger): Use Runtime::kInitializeLegacyConstLookupSlot for 2685 // TODO(mstarzinger): Use Runtime::kInitializeLegacyConstLookupSlot for
2685 // initializations of const declarations. 2686 // initializations of const declarations.
2686 const Operator* op = 2687 const Operator* op =
2687 javascript()->CallRuntime(Runtime::kStoreLookupSlot, 4); 2688 javascript()->CallRuntime(Runtime::kStoreLookupSlot, 4);
2688 Node* store = NewNode(op, value, current_context(), name, strict); 2689 Node* store = NewNode(op, value, current_context(), name, language);
2689 PrepareFrameState(store, bailout_id, combine); 2690 PrepareFrameState(store, bailout_id, combine);
2690 return store; 2691 return store;
2691 } 2692 }
2692 } 2693 }
2693 UNREACHABLE(); 2694 UNREACHABLE();
2694 return NULL; 2695 return NULL;
2695 } 2696 }
2696 2697
2697 2698
2698 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { 2699 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) {
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
3120 Node* dead_node = graph()->NewNode(common()->Dead()); 3121 Node* dead_node = graph()->NewNode(common()->Dead());
3121 dead_control_.set(dead_node); 3122 dead_control_.set(dead_node);
3122 return dead_node; 3123 return dead_node;
3123 } 3124 }
3124 return dead_control_.get(); 3125 return dead_control_.get();
3125 } 3126 }
3126 3127
3127 } // namespace compiler 3128 } // namespace compiler
3128 } // namespace internal 3129 } // namespace internal
3129 } // namespace v8 3130 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698