OLD | NEW |
---|---|
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
725 | 725 |
726 // Record the source position for the property load. | 726 // Record the source position for the property load. |
727 SetSourcePosition(expr->position()); | 727 SetSourcePosition(expr->position()); |
728 | 728 |
729 // Evaluate receiver. | 729 // Evaluate receiver. |
730 Visit(expr->obj()); | 730 Visit(expr->obj()); |
731 | 731 |
732 if (key->AsLiteral() != NULL && key->AsLiteral()->handle()->IsSymbol() && | 732 if (key->AsLiteral() != NULL && key->AsLiteral()->handle()->IsSymbol() && |
733 !String::cast(*(key->AsLiteral()->handle()))->AsArrayIndex(&dummy)) { | 733 !String::cast(*(key->AsLiteral()->handle()))->AsArrayIndex(&dummy)) { |
734 // Do a NAMED property load. | 734 // Do a NAMED property load. |
735 // The IC expects the property name in ecx and the receiver on the stack. | 735 // The IC expects the property name in r2 and the receiver on the stack. |
736 __ mov(r2, Operand(key->AsLiteral()->handle())); | 736 __ mov(r2, Operand(key->AsLiteral()->handle())); |
737 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | 737 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); |
738 __ Call(ic, RelocInfo::CODE_TARGET); | 738 __ Call(ic, RelocInfo::CODE_TARGET); |
739 } else { | 739 } else { |
740 // Do a KEYED property load. | 740 // Do a KEYED property load. |
741 Visit(expr->key()); | 741 Visit(expr->key()); |
742 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); | 742 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); |
743 __ Call(ic, RelocInfo::CODE_TARGET); | 743 __ Call(ic, RelocInfo::CODE_TARGET); |
744 // Drop key and receiver left on the stack by IC. | 744 // Drop key and receiver left on the stack by IC. |
745 __ pop(); | 745 __ pop(); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
908 Visit(args->at(i)); | 908 Visit(args->at(i)); |
909 ASSERT_EQ(Expression::kValue, args->at(i)->context()); | 909 ASSERT_EQ(Expression::kValue, args->at(i)->context()); |
910 } | 910 } |
911 | 911 |
912 __ CallRuntime(function, arg_count); | 912 __ CallRuntime(function, arg_count); |
913 Move(expr->context(), r0); | 913 Move(expr->context(), r0); |
914 } | 914 } |
915 | 915 |
916 | 916 |
917 void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { | 917 void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { |
918 Comment cmnt(masm_, "[ UnaryOperation"); | |
919 switch (expr->op()) { | 918 switch (expr->op()) { |
920 case Token::VOID: | 919 case Token::VOID: { |
920 Comment cmnt(masm_, "[ UnaryOperation (VOID)"); | |
921 Visit(expr->expression()); | 921 Visit(expr->expression()); |
922 ASSERT_EQ(Expression::kEffect, expr->expression()->context()); | 922 ASSERT_EQ(Expression::kEffect, expr->expression()->context()); |
923 switch (expr->context()) { | 923 switch (expr->context()) { |
924 case Expression::kUninitialized: | 924 case Expression::kUninitialized: |
925 UNREACHABLE(); | 925 UNREACHABLE(); |
926 break; | 926 break; |
927 case Expression::kEffect: | 927 case Expression::kEffect: |
928 break; | 928 break; |
929 case Expression::kValue: | 929 case Expression::kValue: |
930 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 930 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
931 __ push(ip); | 931 __ push(ip); |
932 break; | 932 break; |
933 case Expression::kTestValue: | 933 case Expression::kTestValue: |
934 // Value is false so it's needed. | 934 // Value is false so it's needed. |
935 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 935 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
936 __ push(ip); | 936 __ push(ip); |
937 case Expression::kTest: // Fall through. | 937 case Expression::kTest: // Fall through. |
938 case Expression::kValueTest: | 938 case Expression::kValueTest: |
939 __ jmp(false_label_); | 939 __ jmp(false_label_); |
940 break; | 940 break; |
941 } | 941 } |
942 break; | 942 break; |
943 } | |
943 | 944 |
944 case Token::NOT: { | 945 case Token::NOT: { |
946 Comment cmnt(masm_, "[ UnaryOperation (NOT)"); | |
945 ASSERT_EQ(Expression::kTest, expr->expression()->context()); | 947 ASSERT_EQ(Expression::kTest, expr->expression()->context()); |
946 | 948 |
947 Label push_true; | 949 Label push_true; |
948 Label push_false; | 950 Label push_false; |
949 Label done; | 951 Label done; |
950 Label* saved_true = true_label_; | 952 Label* saved_true = true_label_; |
951 Label* saved_false = false_label_; | 953 Label* saved_false = false_label_; |
952 switch (expr->context()) { | 954 switch (expr->context()) { |
953 case Expression::kUninitialized: | 955 case Expression::kUninitialized: |
954 UNREACHABLE(); | 956 UNREACHABLE(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
999 __ LoadRoot(ip, Heap::kFalseValueRootIndex); | 1001 __ LoadRoot(ip, Heap::kFalseValueRootIndex); |
1000 __ push(ip); | 1002 __ push(ip); |
1001 __ jmp(saved_false); | 1003 __ jmp(saved_false); |
1002 break; | 1004 break; |
1003 } | 1005 } |
1004 true_label_ = saved_true; | 1006 true_label_ = saved_true; |
1005 false_label_ = saved_false; | 1007 false_label_ = saved_false; |
1006 break; | 1008 break; |
1007 } | 1009 } |
1008 | 1010 |
1011 case Token::TYPEOF: { | |
1012 Comment cmnt(masm_, "[ UnaryOperation (TYPEOF)"); | |
1013 ASSERT_EQ(Expression::kValue, expr->expression()->context()); | |
1014 | |
1015 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | |
1016 if (proxy != NULL && proxy->var()->is_global()) { | |
1017 Comment cmnt(masm_, "Global variable"); | |
1018 __ ldr(r0, CodeGenerator::GlobalObject()); | |
1019 __ push(r0); | |
1020 __ mov(r2, Operand(proxy->name())); | |
1021 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | |
1022 // Use a regular load, not a contextual load, to avoid reference error. | |
Kevin Millikin (Chromium)
2009/11/05 10:10:26
error => errors :)
| |
1023 __ Call(ic, RelocInfo::CODE_TARGET); | |
1024 __ str(r0, MemOperand(sp)); | |
1025 } else if (proxy != NULL && | |
1026 proxy->var()->slot() != NULL && | |
1027 proxy->var()->slot()->type() == Slot::LOOKUP) { | |
1028 __ mov(r0, Operand(proxy->name())); | |
1029 __ stm(db_w, sp, cp.bit() | r0.bit()); | |
1030 __ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2); | |
1031 __ push(r0); | |
1032 } else { | |
1033 // This expression cannot throw a reference error at the top level. | |
1034 Visit(expr->expression()); | |
1035 } | |
1036 | |
1037 __ CallRuntime(Runtime::kTypeof, 1); | |
1038 Move(expr->context(), r0); | |
1039 break; | |
1040 } | |
1041 | |
1009 default: | 1042 default: |
1010 UNREACHABLE(); | 1043 UNREACHABLE(); |
1011 } | 1044 } |
1012 } | 1045 } |
1013 | 1046 |
1014 | 1047 |
1015 void FastCodeGenerator::VisitCountOperation(CountOperation* expr) { | 1048 void FastCodeGenerator::VisitCountOperation(CountOperation* expr) { |
1016 Comment cmnt(masm_, "[ CountOperation"); | 1049 Comment cmnt(masm_, "[ CountOperation"); |
1017 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 1050 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
1018 ASSERT(proxy->AsVariable() != NULL); | 1051 ASSERT(proxy->AsVariable() != NULL); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1293 true_label_ = saved_true; | 1326 true_label_ = saved_true; |
1294 false_label_ = saved_false; | 1327 false_label_ = saved_false; |
1295 // Convert current context to test context: End post-test code. | 1328 // Convert current context to test context: End post-test code. |
1296 } | 1329 } |
1297 | 1330 |
1298 | 1331 |
1299 #undef __ | 1332 #undef __ |
1300 | 1333 |
1301 | 1334 |
1302 } } // namespace v8::internal | 1335 } } // namespace v8::internal |
OLD | NEW |