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

Side by Side Diff: src/ia32/fast-codegen-ia32.cc

Issue 354027: Implement typeof in fast compiler. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 Visit(args->at(i)); 909 Visit(args->at(i));
910 ASSERT_EQ(Expression::kValue, args->at(i)->context()); 910 ASSERT_EQ(Expression::kValue, args->at(i)->context());
911 } 911 }
912 912
913 __ CallRuntime(function, arg_count); 913 __ CallRuntime(function, arg_count);
914 Move(expr->context(), eax); 914 Move(expr->context(), eax);
915 } 915 }
916 916
917 917
918 void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { 918 void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
919 Comment cmnt(masm_, "[ UnaryOperation");
920 switch (expr->op()) { 919 switch (expr->op()) {
921 case Token::VOID: 920 case Token::VOID: {
921 Comment cmnt(masm_, "[ UnaryOperation (VOID)");
922 Visit(expr->expression()); 922 Visit(expr->expression());
923 ASSERT_EQ(Expression::kEffect, expr->expression()->context()); 923 ASSERT_EQ(Expression::kEffect, expr->expression()->context());
924 switch (expr->context()) { 924 switch (expr->context()) {
925 case Expression::kUninitialized: 925 case Expression::kUninitialized:
926 UNREACHABLE(); 926 UNREACHABLE();
927 break; 927 break;
928 case Expression::kEffect: 928 case Expression::kEffect:
929 break; 929 break;
930 case Expression::kValue: 930 case Expression::kValue:
931 __ push(Immediate(Factory::undefined_value())); 931 __ push(Immediate(Factory::undefined_value()));
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 __ push(Immediate(Factory::undefined_value())); 935 __ push(Immediate(Factory::undefined_value()));
936 // Fall through. 936 // Fall through.
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 __ bind(&push_false); 997 __ bind(&push_false);
996 __ push(Immediate(Factory::false_value())); 998 __ push(Immediate(Factory::false_value()));
997 __ jmp(saved_false); 999 __ jmp(saved_false);
998 break; 1000 break;
999 } 1001 }
1000 true_label_ = saved_true; 1002 true_label_ = saved_true;
1001 false_label_ = saved_false; 1003 false_label_ = saved_false;
1002 break; 1004 break;
1003 } 1005 }
1004 1006
1007 case Token::TYPEOF: {
1008 Comment cmnt(masm_, "[ UnaryOperation (TYPEOF)");
1009 ASSERT_EQ(Expression::kValue, expr->expression()->context());
1010
1011 VariableProxy* proxy = expr->expression()->AsVariableProxy();
1012 if (proxy != NULL && proxy->var()->is_global()) {
1013 Comment cmnt(masm_, "Global variable");
1014 __ push(CodeGenerator::GlobalObject());
1015 __ mov(ecx, Immediate(proxy->name()));
1016 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
1017 // Use a regular load, not a contextual load, to avoid reference error.
1018 __ call(ic, RelocInfo::CODE_TARGET);
1019 __ mov(Operand(esp, 0), eax);
1020 } else if (proxy != NULL &&
1021 proxy->var()->slot() != NULL &&
1022 proxy->var()->slot()->type() == Slot::LOOKUP) {
1023 __ push(esi);
1024 __ push(Immediate(proxy->name()));
1025 __ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2);
1026 __ push(eax);
1027 } else {
1028 // This expression cannot throw a reference error at the top level.
1029 Visit(expr->expression());
1030 }
1031
1032 __ CallRuntime(Runtime::kTypeof, 1);
1033 Move(expr->context(), eax);
1034 break;
1035 }
1036
1005 default: 1037 default:
1006 UNREACHABLE(); 1038 UNREACHABLE();
1007 } 1039 }
1008 } 1040 }
1009 1041
1010 1042
1011 void FastCodeGenerator::VisitCountOperation(CountOperation* expr) { 1043 void FastCodeGenerator::VisitCountOperation(CountOperation* expr) {
1012 Comment cmnt(masm_, "[ CountOperation"); 1044 Comment cmnt(masm_, "[ CountOperation");
1013 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 1045 VariableProxy* proxy = expr->expression()->AsVariableProxy();
1014 ASSERT(proxy->AsVariable() != NULL); 1046 ASSERT(proxy->AsVariable() != NULL);
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 true_label_ = saved_true; 1314 true_label_ = saved_true;
1283 false_label_ = saved_false; 1315 false_label_ = saved_false;
1284 // Convert current context to test context: End post-test code. 1316 // Convert current context to test context: End post-test code.
1285 } 1317 }
1286 1318
1287 1319
1288 #undef __ 1320 #undef __
1289 1321
1290 1322
1291 } } // namespace v8::internal 1323 } } // namespace v8::internal
OLDNEW
« src/arm/fast-codegen-arm.cc ('K') | « src/compiler.cc ('k') | src/x64/fast-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698