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

Side by Side Diff: src/codegen-arm.cc

Issue 2002: Fix performace regression due to missed peephole optimization (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/codegen-ia32.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 masm->CallRuntime(Runtime::kStoreContextSlot, 3); 941 masm->CallRuntime(Runtime::kStoreContextSlot, 3);
942 } 942 }
943 // Storing a variable must keep the (new) value on the expression 943 // Storing a variable must keep the (new) value on the expression
944 // stack. This is necessary for compiling assignment expressions. 944 // stack. This is necessary for compiling assignment expressions.
945 masm->push(r0); 945 masm->push(r0);
946 946
947 } else { 947 } else {
948 ASSERT(var()->mode() != Variable::DYNAMIC); 948 ASSERT(var()->mode() != Variable::DYNAMIC);
949 949
950 Label exit; 950 Label exit;
951 bool skipped_write = false;
951 if (init_state == CONST_INIT) { 952 if (init_state == CONST_INIT) {
952 ASSERT(var()->mode() == Variable::CONST); 953 ASSERT(var()->mode() == Variable::CONST);
953 // Only the first const initialization must be executed (the slot 954 // Only the first const initialization must be executed (the slot
954 // still contains 'the hole' value). When the assignment is executed, 955 // still contains 'the hole' value). When the assignment is executed,
955 // the code is identical to a normal store (see below). 956 // the code is identical to a normal store (see below).
956 Comment cmnt(masm, "[ Init const"); 957 Comment cmnt(masm, "[ Init const");
957 masm->ldr(r2, ArmCodeGenerator::SlotOperand(masm, scope, this, r2)); 958 masm->ldr(r2, ArmCodeGenerator::SlotOperand(masm, scope, this, r2));
958 masm->cmp(r2, Operand(Factory::the_hole_value())); 959 masm->cmp(r2, Operand(Factory::the_hole_value()));
959 masm->b(ne, &exit); 960 masm->b(ne, &exit);
961 skipped_write = true;
960 } 962 }
961 963
962 // We must execute the store. 964 // We must execute the store.
963 // r2 may be loaded with context; used below in RecordWrite. 965 // r2 may be loaded with context; used below in RecordWrite.
964 // Storing a variable must keep the (new) value on the stack. This is 966 // Storing a variable must keep the (new) value on the stack. This is
965 // necessary for compiling assignment expressions. 967 // necessary for compiling assignment expressions.
966 // 968 //
967 // Note: We will reach here even with var()->mode() == Variable::CONST 969 // Note: We will reach here even with var()->mode() == Variable::CONST
968 // because of const declarations which will initialize consts to 'the 970 // because of const declarations which will initialize consts to 'the
969 // hole' value and by doing so, end up calling this code. r2 may be 971 // hole' value and by doing so, end up calling this code. r2 may be
970 // loaded with context; used below in RecordWrite. 972 // loaded with context; used below in RecordWrite.
971 masm->pop(r0); 973 masm->pop(r0);
972 masm->str(r0, ArmCodeGenerator::SlotOperand(masm, scope, this, r2)); 974 masm->str(r0, ArmCodeGenerator::SlotOperand(masm, scope, this, r2));
973 masm->push(r0); 975 masm->push(r0);
974 976
975 if (type() == Slot::CONTEXT) { 977 if (type() == Slot::CONTEXT) {
976 // Skip write barrier if the written value is a smi. 978 // Skip write barrier if the written value is a smi.
977 masm->tst(r0, Operand(kSmiTagMask)); 979 masm->tst(r0, Operand(kSmiTagMask));
978 masm->b(eq, &exit); 980 masm->b(eq, &exit);
979 // r2 is loaded with context when calling SlotOperand above. 981 // r2 is loaded with context when calling SlotOperand above.
980 int offset = FixedArray::kHeaderSize + index() * kPointerSize; 982 int offset = FixedArray::kHeaderSize + index() * kPointerSize;
981 masm->mov(r3, Operand(offset)); 983 masm->mov(r3, Operand(offset));
982 masm->RecordWrite(r2, r3, r1); 984 masm->RecordWrite(r2, r3, r1);
983 } 985 }
984 masm->bind(&exit); 986 // If we did not jump over the assignment, we do not need to bind the
987 // exit label. Doing so can defeat peephole optimization.
988 if (skipped_write) masm->bind(&exit);
iposva 2008/09/11 18:25:11 Why do you introduce a separate variable for testi
985 } 989 }
986 } 990 }
987 991
988 992
989 // ECMA-262, section 9.2, page 30: ToBoolean(). Convert the given 993 // ECMA-262, section 9.2, page 30: ToBoolean(). Convert the given
990 // register to a boolean in the condition code register. The code 994 // register to a boolean in the condition code register. The code
991 // may jump to 'false_target' in case the register converts to 'false'. 995 // may jump to 'false_target' in case the register converts to 'false'.
992 void ArmCodeGenerator::ToBoolean(Label* true_target, 996 void ArmCodeGenerator::ToBoolean(Label* true_target,
993 Label* false_target) { 997 Label* false_target) {
994 // Note: The generated code snippet does not change stack variables. 998 // Note: The generated code snippet does not change stack variables.
(...skipping 3709 matching lines...) Expand 10 before | Expand all | Expand 10 after
4704 bool is_eval) { 4708 bool is_eval) {
4705 Handle<Code> code = ArmCodeGenerator::MakeCode(fun, script, is_eval); 4709 Handle<Code> code = ArmCodeGenerator::MakeCode(fun, script, is_eval);
4706 if (!code.is_null()) { 4710 if (!code.is_null()) {
4707 Counters::total_compiled_code_size.Increment(code->instruction_size()); 4711 Counters::total_compiled_code_size.Increment(code->instruction_size());
4708 } 4712 }
4709 return code; 4713 return code;
4710 } 4714 }
4711 4715
4712 4716
4713 } } // namespace v8::internal 4717 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698