| OLD | NEW |
| 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/control-builders.h" | 8 #include "src/compiler/control-builders.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 stack_dirty_ = false; | 231 stack_dirty_ = false; |
| 232 } | 232 } |
| 233 | 233 |
| 234 Operator* op = common()->FrameState(ast_id); | 234 Operator* op = common()->FrameState(ast_id); |
| 235 | 235 |
| 236 return graph()->NewNode(op, parameters_node_, locals_node_, stack_node_); | 236 return graph()->NewNode(op, parameters_node_, locals_node_, stack_node_); |
| 237 } | 237 } |
| 238 | 238 |
| 239 | 239 |
| 240 AstGraphBuilder::AstContext::AstContext(AstGraphBuilder* own, | 240 AstGraphBuilder::AstContext::AstContext(AstGraphBuilder* own, |
| 241 Expression::Context kind) | 241 Expression::Context kind, |
| 242 : kind_(kind), owner_(own), outer_(own->ast_context()) { | 242 BailoutId bailout_id) |
| 243 : bailout_id_(bailout_id), |
| 244 kind_(kind), |
| 245 owner_(own), |
| 246 outer_(own->ast_context()) { |
| 243 owner()->set_ast_context(this); // Push. | 247 owner()->set_ast_context(this); // Push. |
| 244 #ifdef DEBUG | 248 #ifdef DEBUG |
| 245 original_height_ = environment()->stack_height(); | 249 original_height_ = environment()->stack_height(); |
| 246 #endif | 250 #endif |
| 247 } | 251 } |
| 248 | 252 |
| 249 | 253 |
| 250 AstGraphBuilder::AstContext::~AstContext() { | 254 AstGraphBuilder::AstContext::~AstContext() { |
| 251 owner()->set_ast_context(outer_); // Pop. | 255 owner()->set_ast_context(outer_); // Pop. |
| 252 } | 256 } |
| 253 | 257 |
| 254 | 258 |
| 255 AstGraphBuilder::AstEffectContext::~AstEffectContext() { | 259 AstGraphBuilder::AstEffectContext::~AstEffectContext() { |
| 256 DCHECK(environment()->stack_height() == original_height_); | 260 DCHECK(environment()->stack_height() == original_height_); |
| 257 } | 261 } |
| 258 | 262 |
| 259 | 263 |
| 260 AstGraphBuilder::AstValueContext::~AstValueContext() { | 264 AstGraphBuilder::AstValueContext::~AstValueContext() { |
| 261 DCHECK(environment()->stack_height() == original_height_ + 1); | 265 DCHECK(environment()->stack_height() == original_height_ + 1); |
| 262 } | 266 } |
| 263 | 267 |
| 264 | 268 |
| 265 AstGraphBuilder::AstTestContext::~AstTestContext() { | 269 AstGraphBuilder::AstTestContext::~AstTestContext() { |
| 266 DCHECK(environment()->stack_height() == original_height_ + 1); | 270 DCHECK(environment()->stack_height() == original_height_ + 1); |
| 267 } | 271 } |
| 268 | 272 |
| 269 | 273 |
| 274 void AstGraphBuilder::AstEffectContext::ProduceValueWithLazyBailout( |
| 275 Node* value) { |
| 276 ProduceValue(value); |
| 277 owner()->BuildLazyBailout(value, bailout_id_); |
| 278 } |
| 279 |
| 280 |
| 281 void AstGraphBuilder::AstValueContext::ProduceValueWithLazyBailout( |
| 282 Node* value) { |
| 283 ProduceValue(value); |
| 284 owner()->BuildLazyBailout(value, bailout_id_); |
| 285 } |
| 286 |
| 287 |
| 288 void AstGraphBuilder::AstTestContext::ProduceValueWithLazyBailout(Node* value) { |
| 289 environment()->Push(value); |
| 290 owner()->BuildLazyBailout(value, bailout_id_); |
| 291 environment()->Pop(); |
| 292 ProduceValue(value); |
| 293 } |
| 294 |
| 295 |
| 270 void AstGraphBuilder::AstEffectContext::ProduceValue(Node* value) { | 296 void AstGraphBuilder::AstEffectContext::ProduceValue(Node* value) { |
| 271 // The value is ignored. | 297 // The value is ignored. |
| 272 } | 298 } |
| 273 | 299 |
| 274 | 300 |
| 275 void AstGraphBuilder::AstValueContext::ProduceValue(Node* value) { | 301 void AstGraphBuilder::AstValueContext::ProduceValue(Node* value) { |
| 276 environment()->Push(value); | 302 environment()->Push(value); |
| 277 } | 303 } |
| 278 | 304 |
| 279 | 305 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 352 |
| 327 | 353 |
| 328 void AstGraphBuilder::VisitForValues(ZoneList<Expression*>* exprs) { | 354 void AstGraphBuilder::VisitForValues(ZoneList<Expression*>* exprs) { |
| 329 for (int i = 0; i < exprs->length(); ++i) { | 355 for (int i = 0; i < exprs->length(); ++i) { |
| 330 VisitForValue(exprs->at(i)); | 356 VisitForValue(exprs->at(i)); |
| 331 } | 357 } |
| 332 } | 358 } |
| 333 | 359 |
| 334 | 360 |
| 335 void AstGraphBuilder::VisitForValue(Expression* expr) { | 361 void AstGraphBuilder::VisitForValue(Expression* expr) { |
| 336 AstValueContext for_value(this); | 362 AstValueContext for_value(this, expr->id()); |
| 337 if (!HasStackOverflow()) { | 363 if (!HasStackOverflow()) { |
| 338 expr->Accept(this); | 364 expr->Accept(this); |
| 339 } | 365 } |
| 340 } | 366 } |
| 341 | 367 |
| 342 | 368 |
| 343 void AstGraphBuilder::VisitForEffect(Expression* expr) { | 369 void AstGraphBuilder::VisitForEffect(Expression* expr) { |
| 344 AstEffectContext for_effect(this); | 370 AstEffectContext for_effect(this, expr->id()); |
| 345 if (!HasStackOverflow()) { | 371 if (!HasStackOverflow()) { |
| 346 expr->Accept(this); | 372 expr->Accept(this); |
| 347 } | 373 } |
| 348 } | 374 } |
| 349 | 375 |
| 350 | 376 |
| 351 void AstGraphBuilder::VisitForTest(Expression* expr) { | 377 void AstGraphBuilder::VisitForTest(Expression* expr) { |
| 352 AstTestContext for_condition(this); | 378 AstTestContext for_condition(this, expr->id()); |
| 353 if (!HasStackOverflow()) { | 379 if (!HasStackOverflow()) { |
| 354 expr->Accept(this); | 380 expr->Accept(this); |
| 355 } | 381 } |
| 356 } | 382 } |
| 357 | 383 |
| 358 | 384 |
| 359 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) { | 385 void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) { |
| 360 Variable* variable = decl->proxy()->var(); | 386 Variable* variable = decl->proxy()->var(); |
| 361 VariableMode mode = decl->mode(); | 387 VariableMode mode = decl->mode(); |
| 362 bool hole_init = mode == CONST || mode == CONST_LEGACY || mode == LET; | 388 bool hole_init = mode == CONST || mode == CONST_LEGACY || mode == LET; |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 environment()->Push(cache_length); | 706 environment()->Push(cache_length); |
| 681 environment()->Push(jsgraph()->ZeroConstant()); | 707 environment()->Push(jsgraph()->ZeroConstant()); |
| 682 // PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); | 708 // PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); |
| 683 LoopBuilder for_loop(this); | 709 LoopBuilder for_loop(this); |
| 684 for_loop.BeginLoop(); | 710 for_loop.BeginLoop(); |
| 685 // Check loop termination condition. | 711 // Check loop termination condition. |
| 686 Node* index = environment()->Peek(0); | 712 Node* index = environment()->Peek(0); |
| 687 Node* exit_cond = | 713 Node* exit_cond = |
| 688 NewNode(javascript()->LessThan(), index, cache_length); | 714 NewNode(javascript()->LessThan(), index, cache_length); |
| 689 // TODO(jarin): provide real bailout id. | 715 // TODO(jarin): provide real bailout id. |
| 690 PrepareFrameState(exit_cond, BailoutId::None()); | 716 BuildLazyBailout(exit_cond, BailoutId::None()); |
| 691 for_loop.BreakUnless(exit_cond); | 717 for_loop.BreakUnless(exit_cond); |
| 692 // TODO(dcarney): this runtime call should be a handful of | 718 // TODO(dcarney): this runtime call should be a handful of |
| 693 // simplified instructions that | 719 // simplified instructions that |
| 694 // basically produce | 720 // basically produce |
| 695 // value = array[index] | 721 // value = array[index] |
| 696 environment()->Push(obj); | 722 environment()->Push(obj); |
| 697 environment()->Push(cache_array); | 723 environment()->Push(cache_array); |
| 698 environment()->Push(cache_type); | 724 environment()->Push(cache_type); |
| 699 environment()->Push(index); | 725 environment()->Push(index); |
| 700 Node* pair = | 726 Node* pair = |
| (...skipping 19 matching lines...) Expand all Loading... |
| 720 environment()->Push(jsgraph()->HeapConstant(function)); | 746 environment()->Push(jsgraph()->HeapConstant(function)); |
| 721 // Receiver. | 747 // Receiver. |
| 722 environment()->Push(obj); | 748 environment()->Push(obj); |
| 723 // Args. | 749 // Args. |
| 724 environment()->Push(value); | 750 environment()->Push(value); |
| 725 // result is either the string key or Smi(0) indicating the property | 751 // result is either the string key or Smi(0) indicating the property |
| 726 // is gone. | 752 // is gone. |
| 727 Node* res = ProcessArguments( | 753 Node* res = ProcessArguments( |
| 728 javascript()->Call(3, NO_CALL_FUNCTION_FLAGS), 3); | 754 javascript()->Call(3, NO_CALL_FUNCTION_FLAGS), 3); |
| 729 // TODO(jarin): provide real bailout id. | 755 // TODO(jarin): provide real bailout id. |
| 730 PrepareFrameState(res, BailoutId::None()); | 756 BuildLazyBailout(res, BailoutId::None()); |
| 731 Node* property_missing = NewNode(javascript()->StrictEqual(), res, | 757 Node* property_missing = NewNode(javascript()->StrictEqual(), res, |
| 732 jsgraph()->ZeroConstant()); | 758 jsgraph()->ZeroConstant()); |
| 733 { | 759 { |
| 734 IfBuilder is_property_missing(this); | 760 IfBuilder is_property_missing(this); |
| 735 is_property_missing.If(property_missing); | 761 is_property_missing.If(property_missing); |
| 736 is_property_missing.Then(); | 762 is_property_missing.Then(); |
| 737 // Inc counter and continue. | 763 // Inc counter and continue. |
| 738 Node* index_inc = | 764 Node* index_inc = |
| 739 NewNode(javascript()->Add(), index, jsgraph()->OneConstant()); | 765 NewNode(javascript()->Add(), index, jsgraph()->OneConstant()); |
| 740 environment()->Poke(0, index_inc); | 766 environment()->Poke(0, index_inc); |
| 741 // TODO(jarin): provide real bailout id. | 767 // TODO(jarin): provide real bailout id. |
| 742 PrepareFrameState(index_inc, BailoutId::None()); | 768 BuildLazyBailout(index_inc, BailoutId::None()); |
| 743 for_loop.Continue(); | 769 for_loop.Continue(); |
| 744 is_property_missing.Else(); | 770 is_property_missing.Else(); |
| 745 is_property_missing.End(); | 771 is_property_missing.End(); |
| 746 } | 772 } |
| 747 // Replace 'value' in environment. | 773 // Replace 'value' in environment. |
| 748 environment()->Push(res); | 774 environment()->Push(res); |
| 749 test_should_filter.Else(); | 775 test_should_filter.Else(); |
| 750 test_should_filter.End(); | 776 test_should_filter.End(); |
| 751 } | 777 } |
| 752 value = environment()->Pop(); | 778 value = environment()->Pop(); |
| 753 // Bind value and do loop body. | 779 // Bind value and do loop body. |
| 754 VisitForInAssignment(stmt->each(), value); | 780 VisitForInAssignment(stmt->each(), value); |
| 755 VisitIterationBody(stmt, &for_loop, 5); | 781 VisitIterationBody(stmt, &for_loop, 5); |
| 756 // Inc counter and continue. | 782 // Inc counter and continue. |
| 757 Node* index_inc = | 783 Node* index_inc = |
| 758 NewNode(javascript()->Add(), index, jsgraph()->OneConstant()); | 784 NewNode(javascript()->Add(), index, jsgraph()->OneConstant()); |
| 759 environment()->Poke(0, index_inc); | 785 environment()->Poke(0, index_inc); |
| 760 // TODO(jarin): provide real bailout id. | 786 // TODO(jarin): provide real bailout id. |
| 761 PrepareFrameState(index_inc, BailoutId::None()); | 787 BuildLazyBailout(index_inc, BailoutId::None()); |
| 762 for_loop.EndBody(); | 788 for_loop.EndBody(); |
| 763 for_loop.EndLoop(); | 789 for_loop.EndLoop(); |
| 764 environment()->Drop(5); | 790 environment()->Drop(5); |
| 765 // PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 791 // PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
| 766 } | 792 } |
| 767 have_no_properties.End(); | 793 have_no_properties.End(); |
| 768 } | 794 } |
| 769 is_null.End(); | 795 is_null.End(); |
| 770 } | 796 } |
| 771 is_undefined.End(); | 797 is_undefined.End(); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 case ObjectLiteral::Property::COMPUTED: { | 925 case ObjectLiteral::Property::COMPUTED: { |
| 900 // It is safe to use [[Put]] here because the boilerplate already | 926 // It is safe to use [[Put]] here because the boilerplate already |
| 901 // contains computed properties with an uninitialized value. | 927 // contains computed properties with an uninitialized value. |
| 902 if (key->value()->IsInternalizedString()) { | 928 if (key->value()->IsInternalizedString()) { |
| 903 if (property->emit_store()) { | 929 if (property->emit_store()) { |
| 904 VisitForValue(property->value()); | 930 VisitForValue(property->value()); |
| 905 Node* value = environment()->Pop(); | 931 Node* value = environment()->Pop(); |
| 906 PrintableUnique<Name> name = MakeUnique(key->AsPropertyName()); | 932 PrintableUnique<Name> name = MakeUnique(key->AsPropertyName()); |
| 907 Node* store = | 933 Node* store = |
| 908 NewNode(javascript()->StoreNamed(name), literal, value); | 934 NewNode(javascript()->StoreNamed(name), literal, value); |
| 909 PrepareFrameState(store, key->id()); | 935 BuildLazyBailout(store, key->id()); |
| 910 } else { | 936 } else { |
| 911 VisitForEffect(property->value()); | 937 VisitForEffect(property->value()); |
| 912 } | 938 } |
| 913 break; | 939 break; |
| 914 } | 940 } |
| 915 environment()->Push(literal); // Duplicate receiver. | 941 environment()->Push(literal); // Duplicate receiver. |
| 916 VisitForValue(property->key()); | 942 VisitForValue(property->key()); |
| 917 VisitForValue(property->value()); | 943 VisitForValue(property->value()); |
| 918 Node* value = environment()->Pop(); | 944 Node* value = environment()->Pop(); |
| 919 Node* key = environment()->Pop(); | 945 Node* key = environment()->Pop(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 // Create nodes to evaluate all the non-constant subexpressions and to store | 1017 // Create nodes to evaluate all the non-constant subexpressions and to store |
| 992 // them into the newly cloned array. | 1018 // them into the newly cloned array. |
| 993 for (int i = 0; i < expr->values()->length(); i++) { | 1019 for (int i = 0; i < expr->values()->length(); i++) { |
| 994 Expression* subexpr = expr->values()->at(i); | 1020 Expression* subexpr = expr->values()->at(i); |
| 995 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1021 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
| 996 | 1022 |
| 997 VisitForValue(subexpr); | 1023 VisitForValue(subexpr); |
| 998 Node* value = environment()->Pop(); | 1024 Node* value = environment()->Pop(); |
| 999 Node* index = jsgraph()->Constant(i); | 1025 Node* index = jsgraph()->Constant(i); |
| 1000 Node* store = NewNode(javascript()->StoreProperty(), literal, index, value); | 1026 Node* store = NewNode(javascript()->StoreProperty(), literal, index, value); |
| 1001 PrepareFrameState(store, expr->GetIdForElement(i)); | 1027 BuildLazyBailout(store, expr->GetIdForElement(i)); |
| 1002 } | 1028 } |
| 1003 | 1029 |
| 1004 environment()->Pop(); // Array literal index. | 1030 environment()->Pop(); // Array literal index. |
| 1005 ast_context()->ProduceValue(environment()->Pop()); | 1031 ast_context()->ProduceValue(environment()->Pop()); |
| 1006 } | 1032 } |
| 1007 | 1033 |
| 1008 | 1034 |
| 1009 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) { | 1035 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) { |
| 1010 DCHECK(expr->IsValidReferenceExpression()); | 1036 DCHECK(expr->IsValidReferenceExpression()); |
| 1011 | 1037 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1023 } | 1049 } |
| 1024 case NAMED_PROPERTY: { | 1050 case NAMED_PROPERTY: { |
| 1025 environment()->Push(value); | 1051 environment()->Push(value); |
| 1026 VisitForValue(property->obj()); | 1052 VisitForValue(property->obj()); |
| 1027 Node* object = environment()->Pop(); | 1053 Node* object = environment()->Pop(); |
| 1028 value = environment()->Pop(); | 1054 value = environment()->Pop(); |
| 1029 PrintableUnique<Name> name = | 1055 PrintableUnique<Name> name = |
| 1030 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); | 1056 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); |
| 1031 Node* store = NewNode(javascript()->StoreNamed(name), object, value); | 1057 Node* store = NewNode(javascript()->StoreNamed(name), object, value); |
| 1032 // TODO(jarin) Fill in the correct bailout id. | 1058 // TODO(jarin) Fill in the correct bailout id. |
| 1033 PrepareFrameState(store, BailoutId::None()); | 1059 BuildLazyBailout(store, BailoutId::None()); |
| 1034 break; | 1060 break; |
| 1035 } | 1061 } |
| 1036 case KEYED_PROPERTY: { | 1062 case KEYED_PROPERTY: { |
| 1037 environment()->Push(value); | 1063 environment()->Push(value); |
| 1038 VisitForValue(property->obj()); | 1064 VisitForValue(property->obj()); |
| 1039 VisitForValue(property->key()); | 1065 VisitForValue(property->key()); |
| 1040 Node* key = environment()->Pop(); | 1066 Node* key = environment()->Pop(); |
| 1041 Node* object = environment()->Pop(); | 1067 Node* object = environment()->Pop(); |
| 1042 value = environment()->Pop(); | 1068 value = environment()->Pop(); |
| 1043 Node* store = NewNode(javascript()->StoreProperty(), object, key, value); | 1069 Node* store = NewNode(javascript()->StoreProperty(), object, key, value); |
| 1044 // TODO(jarin) Fill in the correct bailout id. | 1070 // TODO(jarin) Fill in the correct bailout id. |
| 1045 PrepareFrameState(store, BailoutId::None()); | 1071 BuildLazyBailout(store, BailoutId::None()); |
| 1046 break; | 1072 break; |
| 1047 } | 1073 } |
| 1048 } | 1074 } |
| 1049 } | 1075 } |
| 1050 | 1076 |
| 1051 | 1077 |
| 1052 void AstGraphBuilder::VisitAssignment(Assignment* expr) { | 1078 void AstGraphBuilder::VisitAssignment(Assignment* expr) { |
| 1053 DCHECK(expr->target()->IsValidReferenceExpression()); | 1079 DCHECK(expr->target()->IsValidReferenceExpression()); |
| 1054 | 1080 |
| 1055 // Left-hand side can only be a property, a global or a variable slot. | 1081 // Left-hand side can only be a property, a global or a variable slot. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1079 case VARIABLE: { | 1105 case VARIABLE: { |
| 1080 Variable* variable = expr->target()->AsVariableProxy()->var(); | 1106 Variable* variable = expr->target()->AsVariableProxy()->var(); |
| 1081 old_value = BuildVariableLoad(variable, expr->target()->id()); | 1107 old_value = BuildVariableLoad(variable, expr->target()->id()); |
| 1082 break; | 1108 break; |
| 1083 } | 1109 } |
| 1084 case NAMED_PROPERTY: { | 1110 case NAMED_PROPERTY: { |
| 1085 Node* object = environment()->Top(); | 1111 Node* object = environment()->Top(); |
| 1086 PrintableUnique<Name> name = | 1112 PrintableUnique<Name> name = |
| 1087 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); | 1113 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); |
| 1088 old_value = NewNode(javascript()->LoadNamed(name), object); | 1114 old_value = NewNode(javascript()->LoadNamed(name), object); |
| 1089 PrepareFrameState(old_value, property->LoadId(), PUSH_OUTPUT); | 1115 BuildLazyBailoutWithPushedNode(old_value, property->LoadId()); |
| 1090 break; | 1116 break; |
| 1091 } | 1117 } |
| 1092 case KEYED_PROPERTY: { | 1118 case KEYED_PROPERTY: { |
| 1093 Node* key = environment()->Top(); | 1119 Node* key = environment()->Top(); |
| 1094 Node* object = environment()->Peek(1); | 1120 Node* object = environment()->Peek(1); |
| 1095 old_value = NewNode(javascript()->LoadProperty(), object, key); | 1121 old_value = NewNode(javascript()->LoadProperty(), object, key); |
| 1096 PrepareFrameState(old_value, property->LoadId(), PUSH_OUTPUT); | 1122 BuildLazyBailoutWithPushedNode(old_value, property->LoadId()); |
| 1097 break; | 1123 break; |
| 1098 } | 1124 } |
| 1099 } | 1125 } |
| 1100 environment()->Push(old_value); | 1126 environment()->Push(old_value); |
| 1101 VisitForValue(expr->value()); | 1127 VisitForValue(expr->value()); |
| 1102 Node* right = environment()->Pop(); | 1128 Node* right = environment()->Pop(); |
| 1103 Node* left = environment()->Pop(); | 1129 Node* left = environment()->Pop(); |
| 1104 Node* value = BuildBinaryOp(left, right, expr->binary_op()); | 1130 Node* value = BuildBinaryOp(left, right, expr->binary_op()); |
| 1105 environment()->Push(value); | 1131 environment()->Push(value); |
| 1106 PrepareFrameState(value, expr->binary_operation()->id()); | 1132 BuildLazyBailout(value, expr->binary_operation()->id()); |
| 1107 } else { | 1133 } else { |
| 1108 VisitForValue(expr->value()); | 1134 VisitForValue(expr->value()); |
| 1109 } | 1135 } |
| 1110 | 1136 |
| 1111 // Store the value. | 1137 // Store the value. |
| 1112 Node* value = environment()->Pop(); | 1138 Node* value = environment()->Pop(); |
| 1113 switch (assign_type) { | 1139 switch (assign_type) { |
| 1114 case VARIABLE: { | 1140 case VARIABLE: { |
| 1115 Variable* variable = expr->target()->AsVariableProxy()->var(); | 1141 Variable* variable = expr->target()->AsVariableProxy()->var(); |
| 1116 BuildVariableAssignment(variable, value, expr->op(), | 1142 BuildVariableAssignment(variable, value, expr->op(), |
| 1117 expr->AssignmentId()); | 1143 expr->AssignmentId()); |
| 1118 break; | 1144 break; |
| 1119 } | 1145 } |
| 1120 case NAMED_PROPERTY: { | 1146 case NAMED_PROPERTY: { |
| 1121 Node* object = environment()->Pop(); | 1147 Node* object = environment()->Pop(); |
| 1122 PrintableUnique<Name> name = | 1148 PrintableUnique<Name> name = |
| 1123 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); | 1149 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); |
| 1124 Node* store = NewNode(javascript()->StoreNamed(name), object, value); | 1150 Node* store = NewNode(javascript()->StoreNamed(name), object, value); |
| 1125 PrepareFrameState(store, expr->AssignmentId()); | 1151 BuildLazyBailout(store, expr->AssignmentId()); |
| 1126 break; | 1152 break; |
| 1127 } | 1153 } |
| 1128 case KEYED_PROPERTY: { | 1154 case KEYED_PROPERTY: { |
| 1129 Node* key = environment()->Pop(); | 1155 Node* key = environment()->Pop(); |
| 1130 Node* object = environment()->Pop(); | 1156 Node* object = environment()->Pop(); |
| 1131 Node* store = NewNode(javascript()->StoreProperty(), object, key, value); | 1157 Node* store = NewNode(javascript()->StoreProperty(), object, key, value); |
| 1132 PrepareFrameState(store, expr->AssignmentId()); | 1158 BuildLazyBailout(store, expr->AssignmentId()); |
| 1133 break; | 1159 break; |
| 1134 } | 1160 } |
| 1135 } | 1161 } |
| 1136 | 1162 |
| 1137 ast_context()->ProduceValue(value); | 1163 ast_context()->ProduceValue(value); |
| 1138 } | 1164 } |
| 1139 | 1165 |
| 1140 | 1166 |
| 1141 void AstGraphBuilder::VisitYield(Yield* expr) { | 1167 void AstGraphBuilder::VisitYield(Yield* expr) { |
| 1142 VisitForValue(expr->generator_object()); | 1168 VisitForValue(expr->generator_object()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1165 PrintableUnique<Name> name = | 1191 PrintableUnique<Name> name = |
| 1166 MakeUnique(expr->key()->AsLiteral()->AsPropertyName()); | 1192 MakeUnique(expr->key()->AsLiteral()->AsPropertyName()); |
| 1167 value = NewNode(javascript()->LoadNamed(name), object); | 1193 value = NewNode(javascript()->LoadNamed(name), object); |
| 1168 } else { | 1194 } else { |
| 1169 VisitForValue(expr->obj()); | 1195 VisitForValue(expr->obj()); |
| 1170 VisitForValue(expr->key()); | 1196 VisitForValue(expr->key()); |
| 1171 Node* key = environment()->Pop(); | 1197 Node* key = environment()->Pop(); |
| 1172 Node* object = environment()->Pop(); | 1198 Node* object = environment()->Pop(); |
| 1173 value = NewNode(javascript()->LoadProperty(), object, key); | 1199 value = NewNode(javascript()->LoadProperty(), object, key); |
| 1174 } | 1200 } |
| 1175 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 1201 ast_context()->ProduceValueWithLazyBailout(value); |
| 1176 ast_context()->ProduceValue(value); | |
| 1177 } | 1202 } |
| 1178 | 1203 |
| 1179 | 1204 |
| 1180 void AstGraphBuilder::VisitCall(Call* expr) { | 1205 void AstGraphBuilder::VisitCall(Call* expr) { |
| 1181 Expression* callee = expr->expression(); | 1206 Expression* callee = expr->expression(); |
| 1182 Call::CallType call_type = expr->GetCallType(isolate()); | 1207 Call::CallType call_type = expr->GetCallType(isolate()); |
| 1183 | 1208 |
| 1184 // Prepare the callee and the receiver to the function call. This depends on | 1209 // Prepare the callee and the receiver to the function call. This depends on |
| 1185 // the semantics of the underlying call type. | 1210 // the semantics of the underlying call type. |
| 1186 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; | 1211 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1210 Node* object = environment()->Top(); | 1235 Node* object = environment()->Top(); |
| 1211 if (property->key()->IsPropertyName()) { | 1236 if (property->key()->IsPropertyName()) { |
| 1212 PrintableUnique<Name> name = | 1237 PrintableUnique<Name> name = |
| 1213 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); | 1238 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); |
| 1214 callee_value = NewNode(javascript()->LoadNamed(name), object); | 1239 callee_value = NewNode(javascript()->LoadNamed(name), object); |
| 1215 } else { | 1240 } else { |
| 1216 VisitForValue(property->key()); | 1241 VisitForValue(property->key()); |
| 1217 Node* key = environment()->Pop(); | 1242 Node* key = environment()->Pop(); |
| 1218 callee_value = NewNode(javascript()->LoadProperty(), object, key); | 1243 callee_value = NewNode(javascript()->LoadProperty(), object, key); |
| 1219 } | 1244 } |
| 1220 PrepareFrameState(callee_value, property->LoadId(), PUSH_OUTPUT); | 1245 BuildLazyBailoutWithPushedNode(callee_value, property->LoadId()); |
| 1221 receiver_value = environment()->Pop(); | 1246 receiver_value = environment()->Pop(); |
| 1222 // Note that a PROPERTY_CALL requires the receiver to be wrapped into an | 1247 // Note that a PROPERTY_CALL requires the receiver to be wrapped into an |
| 1223 // object for sloppy callees. This could also be modeled explicitly here, | 1248 // object for sloppy callees. This could also be modeled explicitly here, |
| 1224 // thereby obsoleting the need for a flag to the call operator. | 1249 // thereby obsoleting the need for a flag to the call operator. |
| 1225 flags = CALL_AS_METHOD; | 1250 flags = CALL_AS_METHOD; |
| 1226 break; | 1251 break; |
| 1227 } | 1252 } |
| 1228 case Call::POSSIBLY_EVAL_CALL: | 1253 case Call::POSSIBLY_EVAL_CALL: |
| 1229 possibly_eval = true; | 1254 possibly_eval = true; |
| 1230 // Fall through. | 1255 // Fall through. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 Node* new_receiver = NewNode(common()->Projection(1), pair); | 1290 Node* new_receiver = NewNode(common()->Projection(1), pair); |
| 1266 | 1291 |
| 1267 // Patch callee and receiver on the environment. | 1292 // Patch callee and receiver on the environment. |
| 1268 environment()->Poke(arg_count + 1, new_callee); | 1293 environment()->Poke(arg_count + 1, new_callee); |
| 1269 environment()->Poke(arg_count + 0, new_receiver); | 1294 environment()->Poke(arg_count + 0, new_receiver); |
| 1270 } | 1295 } |
| 1271 | 1296 |
| 1272 // Create node to perform the function call. | 1297 // Create node to perform the function call. |
| 1273 Operator* call = javascript()->Call(args->length() + 2, flags); | 1298 Operator* call = javascript()->Call(args->length() + 2, flags); |
| 1274 Node* value = ProcessArguments(call, args->length() + 2); | 1299 Node* value = ProcessArguments(call, args->length() + 2); |
| 1275 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 1300 ast_context()->ProduceValueWithLazyBailout(value); |
| 1276 ast_context()->ProduceValue(value); | |
| 1277 } | 1301 } |
| 1278 | 1302 |
| 1279 | 1303 |
| 1280 void AstGraphBuilder::VisitCallNew(CallNew* expr) { | 1304 void AstGraphBuilder::VisitCallNew(CallNew* expr) { |
| 1281 VisitForValue(expr->expression()); | 1305 VisitForValue(expr->expression()); |
| 1282 | 1306 |
| 1283 // Evaluate all arguments to the construct call. | 1307 // Evaluate all arguments to the construct call. |
| 1284 ZoneList<Expression*>* args = expr->arguments(); | 1308 ZoneList<Expression*>* args = expr->arguments(); |
| 1285 VisitForValues(args); | 1309 VisitForValues(args); |
| 1286 | 1310 |
| 1287 // Create node to perform the construct call. | 1311 // Create node to perform the construct call. |
| 1288 Operator* call = javascript()->CallNew(args->length() + 1); | 1312 Operator* call = javascript()->CallNew(args->length() + 1); |
| 1289 Node* value = ProcessArguments(call, args->length() + 1); | 1313 Node* value = ProcessArguments(call, args->length() + 1); |
| 1290 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 1314 ast_context()->ProduceValueWithLazyBailout(value); |
| 1291 ast_context()->ProduceValue(value); | |
| 1292 } | 1315 } |
| 1293 | 1316 |
| 1294 | 1317 |
| 1295 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { | 1318 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { |
| 1296 Handle<String> name = expr->name(); | 1319 Handle<String> name = expr->name(); |
| 1297 | 1320 |
| 1298 // The callee and the receiver both have to be pushed onto the operand stack | 1321 // The callee and the receiver both have to be pushed onto the operand stack |
| 1299 // before arguments are being evaluated. | 1322 // before arguments are being evaluated. |
| 1300 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; | 1323 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; |
| 1301 Node* receiver_value = BuildLoadBuiltinsObject(); | 1324 Node* receiver_value = BuildLoadBuiltinsObject(); |
| 1302 PrintableUnique<String> unique = MakeUnique(name); | 1325 PrintableUnique<String> unique = MakeUnique(name); |
| 1303 Node* callee_value = NewNode(javascript()->LoadNamed(unique), receiver_value); | 1326 Node* callee_value = NewNode(javascript()->LoadNamed(unique), receiver_value); |
| 1304 environment()->Push(callee_value); | 1327 environment()->Push(callee_value); |
| 1305 // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft | 1328 // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft |
| 1306 // refuses to optimize functions with jsruntime calls). | 1329 // refuses to optimize functions with jsruntime calls). |
| 1307 PrepareFrameState(callee_value, BailoutId::None()); | 1330 BuildLazyBailout(callee_value, BailoutId::None()); |
| 1308 environment()->Push(receiver_value); | 1331 environment()->Push(receiver_value); |
| 1309 | 1332 |
| 1310 // Evaluate all arguments to the JS runtime call. | 1333 // Evaluate all arguments to the JS runtime call. |
| 1311 ZoneList<Expression*>* args = expr->arguments(); | 1334 ZoneList<Expression*>* args = expr->arguments(); |
| 1312 VisitForValues(args); | 1335 VisitForValues(args); |
| 1313 | 1336 |
| 1314 // Create node to perform the JS runtime call. | 1337 // Create node to perform the JS runtime call. |
| 1315 Operator* call = javascript()->Call(args->length() + 2, flags); | 1338 Operator* call = javascript()->Call(args->length() + 2, flags); |
| 1316 Node* value = ProcessArguments(call, args->length() + 2); | 1339 Node* value = ProcessArguments(call, args->length() + 2); |
| 1317 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 1340 ast_context()->ProduceValueWithLazyBailout(value); |
| 1318 ast_context()->ProduceValue(value); | |
| 1319 } | 1341 } |
| 1320 | 1342 |
| 1321 | 1343 |
| 1322 void AstGraphBuilder::VisitCallRuntime(CallRuntime* expr) { | 1344 void AstGraphBuilder::VisitCallRuntime(CallRuntime* expr) { |
| 1323 const Runtime::Function* function = expr->function(); | 1345 const Runtime::Function* function = expr->function(); |
| 1324 | 1346 |
| 1325 // Handle calls to runtime functions implemented in JavaScript separately as | 1347 // Handle calls to runtime functions implemented in JavaScript separately as |
| 1326 // the call follows JavaScript ABI and the callee is statically unknown. | 1348 // the call follows JavaScript ABI and the callee is statically unknown. |
| 1327 if (expr->is_jsruntime()) { | 1349 if (expr->is_jsruntime()) { |
| 1328 DCHECK(function == NULL && expr->name()->length() > 0); | 1350 DCHECK(function == NULL && expr->name()->length() > 0); |
| 1329 return VisitCallJSRuntime(expr); | 1351 return VisitCallJSRuntime(expr); |
| 1330 } | 1352 } |
| 1331 | 1353 |
| 1332 // Evaluate all arguments to the runtime call. | 1354 // Evaluate all arguments to the runtime call. |
| 1333 ZoneList<Expression*>* args = expr->arguments(); | 1355 ZoneList<Expression*>* args = expr->arguments(); |
| 1334 VisitForValues(args); | 1356 VisitForValues(args); |
| 1335 | 1357 |
| 1336 // Create node to perform the runtime call. | 1358 // Create node to perform the runtime call. |
| 1337 Runtime::FunctionId functionId = function->function_id; | 1359 Runtime::FunctionId functionId = function->function_id; |
| 1338 Operator* call = javascript()->Runtime(functionId, args->length()); | 1360 Operator* call = javascript()->Runtime(functionId, args->length()); |
| 1339 Node* value = ProcessArguments(call, args->length()); | 1361 Node* value = ProcessArguments(call, args->length()); |
| 1340 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 1362 ast_context()->ProduceValueWithLazyBailout(value); |
| 1341 ast_context()->ProduceValue(value); | |
| 1342 } | 1363 } |
| 1343 | 1364 |
| 1344 | 1365 |
| 1345 void AstGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { | 1366 void AstGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { |
| 1346 switch (expr->op()) { | 1367 switch (expr->op()) { |
| 1347 case Token::DELETE: | 1368 case Token::DELETE: |
| 1348 return VisitDelete(expr); | 1369 return VisitDelete(expr); |
| 1349 case Token::VOID: | 1370 case Token::VOID: |
| 1350 return VisitVoid(expr); | 1371 return VisitVoid(expr); |
| 1351 case Token::TYPEOF: | 1372 case Token::TYPEOF: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1378 old_value = BuildVariableLoad(variable, expr->expression()->id()); | 1399 old_value = BuildVariableLoad(variable, expr->expression()->id()); |
| 1379 stack_depth = 0; | 1400 stack_depth = 0; |
| 1380 break; | 1401 break; |
| 1381 } | 1402 } |
| 1382 case NAMED_PROPERTY: { | 1403 case NAMED_PROPERTY: { |
| 1383 VisitForValue(property->obj()); | 1404 VisitForValue(property->obj()); |
| 1384 Node* object = environment()->Top(); | 1405 Node* object = environment()->Top(); |
| 1385 PrintableUnique<Name> name = | 1406 PrintableUnique<Name> name = |
| 1386 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); | 1407 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); |
| 1387 old_value = NewNode(javascript()->LoadNamed(name), object); | 1408 old_value = NewNode(javascript()->LoadNamed(name), object); |
| 1388 PrepareFrameState(old_value, property->LoadId(), PUSH_OUTPUT); | 1409 BuildLazyBailoutWithPushedNode(old_value, property->LoadId()); |
| 1389 stack_depth = 1; | 1410 stack_depth = 1; |
| 1390 break; | 1411 break; |
| 1391 } | 1412 } |
| 1392 case KEYED_PROPERTY: { | 1413 case KEYED_PROPERTY: { |
| 1393 VisitForValue(property->obj()); | 1414 VisitForValue(property->obj()); |
| 1394 VisitForValue(property->key()); | 1415 VisitForValue(property->key()); |
| 1395 Node* key = environment()->Top(); | 1416 Node* key = environment()->Top(); |
| 1396 Node* object = environment()->Peek(1); | 1417 Node* object = environment()->Peek(1); |
| 1397 old_value = NewNode(javascript()->LoadProperty(), object, key); | 1418 old_value = NewNode(javascript()->LoadProperty(), object, key); |
| 1398 PrepareFrameState(old_value, property->LoadId(), PUSH_OUTPUT); | 1419 BuildLazyBailoutWithPushedNode(old_value, property->LoadId()); |
| 1399 stack_depth = 2; | 1420 stack_depth = 2; |
| 1400 break; | 1421 break; |
| 1401 } | 1422 } |
| 1402 } | 1423 } |
| 1403 | 1424 |
| 1404 // Convert old value into a number. | 1425 // Convert old value into a number. |
| 1405 old_value = NewNode(javascript()->ToNumber(), old_value); | 1426 old_value = NewNode(javascript()->ToNumber(), old_value); |
| 1406 | 1427 |
| 1407 // Save result for postfix expressions at correct stack depth. | 1428 // Save result for postfix expressions at correct stack depth. |
| 1408 if (is_postfix) environment()->Poke(stack_depth, old_value); | 1429 if (is_postfix) environment()->Poke(stack_depth, old_value); |
| 1409 | 1430 |
| 1410 // Create node to perform +1/-1 operation. | 1431 // Create node to perform +1/-1 operation. |
| 1411 Node* value = | 1432 Node* value = |
| 1412 BuildBinaryOp(old_value, jsgraph()->OneConstant(), expr->binary_op()); | 1433 BuildBinaryOp(old_value, jsgraph()->OneConstant(), expr->binary_op()); |
| 1413 // TODO(jarin) Insert proper bailout id here (will need to change | 1434 // TODO(jarin) Insert proper bailout id here (will need to change |
| 1414 // full code generator). | 1435 // full code generator). |
| 1415 PrepareFrameState(value, BailoutId::None()); | 1436 BuildLazyBailout(value, BailoutId::None()); |
| 1416 | 1437 |
| 1417 // Store the value. | 1438 // Store the value. |
| 1418 switch (assign_type) { | 1439 switch (assign_type) { |
| 1419 case VARIABLE: { | 1440 case VARIABLE: { |
| 1420 Variable* variable = expr->expression()->AsVariableProxy()->var(); | 1441 Variable* variable = expr->expression()->AsVariableProxy()->var(); |
| 1421 BuildVariableAssignment(variable, value, expr->op(), | 1442 BuildVariableAssignment(variable, value, expr->op(), |
| 1422 expr->AssignmentId()); | 1443 expr->AssignmentId()); |
| 1423 break; | 1444 break; |
| 1424 } | 1445 } |
| 1425 case NAMED_PROPERTY: { | 1446 case NAMED_PROPERTY: { |
| 1426 Node* object = environment()->Pop(); | 1447 Node* object = environment()->Pop(); |
| 1427 PrintableUnique<Name> name = | 1448 PrintableUnique<Name> name = |
| 1428 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); | 1449 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); |
| 1429 Node* store = NewNode(javascript()->StoreNamed(name), object, value); | 1450 Node* store = NewNode(javascript()->StoreNamed(name), object, value); |
| 1430 PrepareFrameState(store, expr->AssignmentId()); | 1451 BuildLazyBailout(store, expr->AssignmentId()); |
| 1431 break; | 1452 break; |
| 1432 } | 1453 } |
| 1433 case KEYED_PROPERTY: { | 1454 case KEYED_PROPERTY: { |
| 1434 Node* key = environment()->Pop(); | 1455 Node* key = environment()->Pop(); |
| 1435 Node* object = environment()->Pop(); | 1456 Node* object = environment()->Pop(); |
| 1436 Node* store = NewNode(javascript()->StoreProperty(), object, key, value); | 1457 Node* store = NewNode(javascript()->StoreProperty(), object, key, value); |
| 1437 PrepareFrameState(store, expr->AssignmentId()); | 1458 BuildLazyBailout(store, expr->AssignmentId()); |
| 1438 break; | 1459 break; |
| 1439 } | 1460 } |
| 1440 } | 1461 } |
| 1441 | 1462 |
| 1442 // Restore old value for postfix expressions. | 1463 // Restore old value for postfix expressions. |
| 1443 if (is_postfix) value = environment()->Pop(); | 1464 if (is_postfix) value = environment()->Pop(); |
| 1444 | 1465 |
| 1445 ast_context()->ProduceValue(value); | 1466 ast_context()->ProduceValue(value); |
| 1446 } | 1467 } |
| 1447 | 1468 |
| 1448 | 1469 |
| 1449 void AstGraphBuilder::VisitBinaryOperation(BinaryOperation* expr) { | 1470 void AstGraphBuilder::VisitBinaryOperation(BinaryOperation* expr) { |
| 1450 switch (expr->op()) { | 1471 switch (expr->op()) { |
| 1451 case Token::COMMA: | 1472 case Token::COMMA: |
| 1452 return VisitComma(expr); | 1473 return VisitComma(expr); |
| 1453 case Token::OR: | 1474 case Token::OR: |
| 1454 case Token::AND: | 1475 case Token::AND: |
| 1455 return VisitLogicalExpression(expr); | 1476 return VisitLogicalExpression(expr); |
| 1456 default: { | 1477 default: { |
| 1457 VisitForValue(expr->left()); | 1478 VisitForValue(expr->left()); |
| 1458 VisitForValue(expr->right()); | 1479 VisitForValue(expr->right()); |
| 1459 Node* right = environment()->Pop(); | 1480 Node* right = environment()->Pop(); |
| 1460 Node* left = environment()->Pop(); | 1481 Node* left = environment()->Pop(); |
| 1461 Node* value = BuildBinaryOp(left, right, expr->op()); | 1482 Node* value = BuildBinaryOp(left, right, expr->op()); |
| 1462 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 1483 ast_context()->ProduceValueWithLazyBailout(value); |
| 1463 ast_context()->ProduceValue(value); | |
| 1464 } | 1484 } |
| 1465 } | 1485 } |
| 1466 } | 1486 } |
| 1467 | 1487 |
| 1468 | 1488 |
| 1469 void AstGraphBuilder::VisitCompareOperation(CompareOperation* expr) { | 1489 void AstGraphBuilder::VisitCompareOperation(CompareOperation* expr) { |
| 1470 Operator* op; | 1490 Operator* op; |
| 1471 switch (expr->op()) { | 1491 switch (expr->op()) { |
| 1472 case Token::EQ: | 1492 case Token::EQ: |
| 1473 op = javascript()->Equal(); | 1493 op = javascript()->Equal(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1503 op = NULL; | 1523 op = NULL; |
| 1504 UNREACHABLE(); | 1524 UNREACHABLE(); |
| 1505 } | 1525 } |
| 1506 VisitForValue(expr->left()); | 1526 VisitForValue(expr->left()); |
| 1507 VisitForValue(expr->right()); | 1527 VisitForValue(expr->right()); |
| 1508 Node* right = environment()->Pop(); | 1528 Node* right = environment()->Pop(); |
| 1509 Node* left = environment()->Pop(); | 1529 Node* left = environment()->Pop(); |
| 1510 Node* value = NewNode(op, left, right); | 1530 Node* value = NewNode(op, left, right); |
| 1511 ast_context()->ProduceValue(value); | 1531 ast_context()->ProduceValue(value); |
| 1512 | 1532 |
| 1513 PrepareFrameState(value, expr->id()); | 1533 BuildLazyBailout(value, expr->id()); |
| 1514 } | 1534 } |
| 1515 | 1535 |
| 1516 | 1536 |
| 1517 void AstGraphBuilder::VisitThisFunction(ThisFunction* expr) { | 1537 void AstGraphBuilder::VisitThisFunction(ThisFunction* expr) { |
| 1518 Node* value = GetFunctionClosure(); | 1538 Node* value = GetFunctionClosure(); |
| 1519 ast_context()->ProduceValue(value); | 1539 ast_context()->ProduceValue(value); |
| 1520 } | 1540 } |
| 1521 | 1541 |
| 1522 | 1542 |
| 1523 void AstGraphBuilder::VisitCaseClause(CaseClause* expr) { UNREACHABLE(); } | 1543 void AstGraphBuilder::VisitCaseClause(CaseClause* expr) { UNREACHABLE(); } |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 ContextualMode contextual_mode) { | 1753 ContextualMode contextual_mode) { |
| 1734 Node* the_hole = jsgraph()->TheHoleConstant(); | 1754 Node* the_hole = jsgraph()->TheHoleConstant(); |
| 1735 VariableMode mode = variable->mode(); | 1755 VariableMode mode = variable->mode(); |
| 1736 switch (variable->location()) { | 1756 switch (variable->location()) { |
| 1737 case Variable::UNALLOCATED: { | 1757 case Variable::UNALLOCATED: { |
| 1738 // Global var, const, or let variable. | 1758 // Global var, const, or let variable. |
| 1739 Node* global = BuildLoadGlobalObject(); | 1759 Node* global = BuildLoadGlobalObject(); |
| 1740 PrintableUnique<Name> name = MakeUnique(variable->name()); | 1760 PrintableUnique<Name> name = MakeUnique(variable->name()); |
| 1741 Operator* op = javascript()->LoadNamed(name, contextual_mode); | 1761 Operator* op = javascript()->LoadNamed(name, contextual_mode); |
| 1742 Node* node = NewNode(op, global); | 1762 Node* node = NewNode(op, global); |
| 1743 PrepareFrameState(node, bailout_id, PUSH_OUTPUT); | 1763 BuildLazyBailoutWithPushedNode(node, bailout_id); |
| 1744 return node; | 1764 return node; |
| 1745 } | 1765 } |
| 1746 case Variable::PARAMETER: | 1766 case Variable::PARAMETER: |
| 1747 case Variable::LOCAL: { | 1767 case Variable::LOCAL: { |
| 1748 // Local var, const, or let variable. | 1768 // Local var, const, or let variable. |
| 1749 Node* value = environment()->Lookup(variable); | 1769 Node* value = environment()->Lookup(variable); |
| 1750 if (mode == CONST_LEGACY) { | 1770 if (mode == CONST_LEGACY) { |
| 1751 // Perform check for uninitialized legacy const variables. | 1771 // Perform check for uninitialized legacy const variables. |
| 1752 if (value->op() == the_hole->op()) { | 1772 if (value->op() == the_hole->op()) { |
| 1753 value = jsgraph()->UndefinedConstant(); | 1773 value = jsgraph()->UndefinedConstant(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1834 BailoutId bailout_id) { | 1854 BailoutId bailout_id) { |
| 1835 Node* the_hole = jsgraph()->TheHoleConstant(); | 1855 Node* the_hole = jsgraph()->TheHoleConstant(); |
| 1836 VariableMode mode = variable->mode(); | 1856 VariableMode mode = variable->mode(); |
| 1837 switch (variable->location()) { | 1857 switch (variable->location()) { |
| 1838 case Variable::UNALLOCATED: { | 1858 case Variable::UNALLOCATED: { |
| 1839 // Global var, const, or let variable. | 1859 // Global var, const, or let variable. |
| 1840 Node* global = BuildLoadGlobalObject(); | 1860 Node* global = BuildLoadGlobalObject(); |
| 1841 PrintableUnique<Name> name = MakeUnique(variable->name()); | 1861 PrintableUnique<Name> name = MakeUnique(variable->name()); |
| 1842 Operator* op = javascript()->StoreNamed(name); | 1862 Operator* op = javascript()->StoreNamed(name); |
| 1843 Node* store = NewNode(op, global, value); | 1863 Node* store = NewNode(op, global, value); |
| 1844 PrepareFrameState(store, bailout_id); | 1864 BuildLazyBailout(store, bailout_id); |
| 1845 return store; | 1865 return store; |
| 1846 } | 1866 } |
| 1847 case Variable::PARAMETER: | 1867 case Variable::PARAMETER: |
| 1848 case Variable::LOCAL: | 1868 case Variable::LOCAL: |
| 1849 // Local var, const, or let variable. | 1869 // Local var, const, or let variable. |
| 1850 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { | 1870 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { |
| 1851 // Perform an initialization check for legacy const variables. | 1871 // Perform an initialization check for legacy const variables. |
| 1852 Node* current = environment()->Lookup(variable); | 1872 Node* current = environment()->Lookup(variable); |
| 1853 if (current->op() != the_hole->op()) { | 1873 if (current->op() != the_hole->op()) { |
| 1854 value = BuildHoleCheckSilent(current, value, current); | 1874 value = BuildHoleCheckSilent(current, value, current); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1986 js_op = javascript()->Modulus(); | 2006 js_op = javascript()->Modulus(); |
| 1987 break; | 2007 break; |
| 1988 default: | 2008 default: |
| 1989 UNREACHABLE(); | 2009 UNREACHABLE(); |
| 1990 js_op = NULL; | 2010 js_op = NULL; |
| 1991 } | 2011 } |
| 1992 return NewNode(js_op, left, right); | 2012 return NewNode(js_op, left, right); |
| 1993 } | 2013 } |
| 1994 | 2014 |
| 1995 | 2015 |
| 1996 void AstGraphBuilder::PrepareFrameState(Node* node, BailoutId ast_id, | 2016 void AstGraphBuilder::BuildLazyBailout(Node* node, BailoutId ast_id) { |
| 1997 OutputFrameStateCombine combine) { | |
| 1998 if (OperatorProperties::CanLazilyDeoptimize(node->op())) { | 2017 if (OperatorProperties::CanLazilyDeoptimize(node->op())) { |
| 1999 // The deopting node should have an outgoing control dependency. | 2018 // The deopting node should have an outgoing control dependency. |
| 2000 DCHECK(environment()->GetControlDependency() == node); | 2019 DCHECK(environment()->GetControlDependency() == node); |
| 2001 | 2020 |
| 2002 if (combine == PUSH_OUTPUT) { | |
| 2003 environment()->Push(node); | |
| 2004 } | |
| 2005 | |
| 2006 StructuredGraphBuilder::Environment* continuation_env = environment(); | 2021 StructuredGraphBuilder::Environment* continuation_env = environment(); |
| 2007 // Create environment for the deoptimization block, and build the block. | 2022 // Create environment for the deoptimization block, and build the block. |
| 2008 StructuredGraphBuilder::Environment* deopt_env = | 2023 StructuredGraphBuilder::Environment* deopt_env = |
| 2009 CopyEnvironment(continuation_env); | 2024 CopyEnvironment(continuation_env); |
| 2010 set_environment(deopt_env); | 2025 set_environment(deopt_env); |
| 2011 | 2026 |
| 2012 NewNode(common()->LazyDeoptimization()); | 2027 NewNode(common()->LazyDeoptimization()); |
| 2013 | 2028 |
| 2014 // TODO(jarin) If ast_id.IsNone(), perhaps we should generate an empty | 2029 // TODO(jarin) If ast_id.IsNone(), perhaps we should generate an empty |
| 2015 // deopt block and make sure there is no patch entry for this (so | 2030 // deopt block and make sure there is no patch entry for this (so |
| 2016 // that the deoptimizer dies when trying to deoptimize here). | 2031 // that the deoptimizer dies when trying to deoptimize here). |
| 2017 | 2032 |
| 2018 Node* state_node = environment()->Checkpoint(ast_id); | 2033 Node* state_node = environment()->Checkpoint(ast_id); |
| 2019 | 2034 |
| 2020 Node* deoptimize_node = NewNode(common()->Deoptimize(), state_node); | 2035 Node* deoptimize_node = NewNode(common()->Deoptimize(), state_node); |
| 2021 | 2036 |
| 2022 UpdateControlDependencyToLeaveFunction(deoptimize_node); | 2037 UpdateControlDependencyToLeaveFunction(deoptimize_node); |
| 2023 | 2038 |
| 2024 // Continue with the original environment. | 2039 // Continue with the original environment. |
| 2025 set_environment(continuation_env); | 2040 set_environment(continuation_env); |
| 2026 | 2041 |
| 2027 if (combine == PUSH_OUTPUT) { | |
| 2028 environment()->Pop(); | |
| 2029 } | |
| 2030 | |
| 2031 NewNode(common()->Continuation()); | 2042 NewNode(common()->Continuation()); |
| 2032 } | 2043 } |
| 2033 } | 2044 } |
| 2034 | 2045 |
| 2046 |
| 2047 void AstGraphBuilder::BuildLazyBailoutWithPushedNode(Node* node, |
| 2048 BailoutId ast_id) { |
| 2049 environment()->Push(node); |
| 2050 BuildLazyBailout(node, ast_id); |
| 2051 environment()->Pop(); |
| 2052 } |
| 2035 } | 2053 } |
| 2036 } | 2054 } |
| 2037 } // namespace v8::internal::compiler | 2055 } // namespace v8::internal::compiler |
| OLD | NEW |