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

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

Issue 10905308: Do not go to slow mode and back to fast in initializer blocks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | « src/ast.cc ('k') | src/parser.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 2132
2133 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { 2133 void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
2134 // Assignment to a property, using a named store IC. 2134 // Assignment to a property, using a named store IC.
2135 // eax : value 2135 // eax : value
2136 // esp[0] : receiver 2136 // esp[0] : receiver
2137 2137
2138 Property* prop = expr->target()->AsProperty(); 2138 Property* prop = expr->target()->AsProperty();
2139 ASSERT(prop != NULL); 2139 ASSERT(prop != NULL);
2140 ASSERT(prop->key()->AsLiteral() != NULL); 2140 ASSERT(prop->key()->AsLiteral() != NULL);
2141 2141
2142 // If the assignment starts a block of assignments to the same object,
2143 // change to slow case to avoid the quadratic behavior of repeatedly
2144 // adding fast properties.
2145 if (expr->starts_initialization_block()) {
2146 __ push(result_register());
2147 __ push(Operand(esp, kPointerSize)); // Receiver is now under value.
2148 __ CallRuntime(Runtime::kToSlowProperties, 1);
2149 __ pop(result_register());
2150 }
2151
2152 // Record source code position before IC call. 2142 // Record source code position before IC call.
2153 SetSourcePosition(expr->position()); 2143 SetSourcePosition(expr->position());
2154 __ mov(ecx, prop->key()->AsLiteral()->handle()); 2144 __ mov(ecx, prop->key()->AsLiteral()->handle());
2155 if (expr->ends_initialization_block()) { 2145 __ pop(edx);
2156 __ mov(edx, Operand(esp, 0));
2157 } else {
2158 __ pop(edx);
2159 }
2160 Handle<Code> ic = is_classic_mode() 2146 Handle<Code> ic = is_classic_mode()
2161 ? isolate()->builtins()->StoreIC_Initialize() 2147 ? isolate()->builtins()->StoreIC_Initialize()
2162 : isolate()->builtins()->StoreIC_Initialize_Strict(); 2148 : isolate()->builtins()->StoreIC_Initialize_Strict();
2163 CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); 2149 CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId());
2164 2150
2165 // If the assignment ends an initialization block, revert to fast case.
2166 if (expr->ends_initialization_block()) {
2167 __ push(eax); // Result of assignment, saved even if not needed.
2168 __ push(Operand(esp, kPointerSize)); // Receiver is under value.
2169 __ CallRuntime(Runtime::kToFastProperties, 1);
2170 __ pop(eax);
2171 __ Drop(1);
2172 }
2173 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); 2151 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
2174 context()->Plug(eax); 2152 context()->Plug(eax);
2175 } 2153 }
2176 2154
2177 2155
2178 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { 2156 void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
2179 // Assignment to a property, using a keyed store IC. 2157 // Assignment to a property, using a keyed store IC.
2180 // eax : value 2158 // eax : value
2181 // esp[0] : key 2159 // esp[0] : key
2182 // esp[kPointerSize] : receiver 2160 // esp[kPointerSize] : receiver
2183 2161
2184 // If the assignment starts a block of assignments to the same object,
2185 // change to slow case to avoid the quadratic behavior of repeatedly
2186 // adding fast properties.
2187 if (expr->starts_initialization_block()) {
2188 __ push(result_register());
2189 // Receiver is now under the key and value.
2190 __ push(Operand(esp, 2 * kPointerSize));
2191 __ CallRuntime(Runtime::kToSlowProperties, 1);
2192 __ pop(result_register());
2193 }
2194
2195 __ pop(ecx); // Key. 2162 __ pop(ecx); // Key.
2196 if (expr->ends_initialization_block()) { 2163 __ pop(edx);
2197 __ mov(edx, Operand(esp, 0)); // Leave receiver on the stack for later.
2198 } else {
2199 __ pop(edx);
2200 }
2201 // Record source code position before IC call. 2164 // Record source code position before IC call.
2202 SetSourcePosition(expr->position()); 2165 SetSourcePosition(expr->position());
2203 Handle<Code> ic = is_classic_mode() 2166 Handle<Code> ic = is_classic_mode()
2204 ? isolate()->builtins()->KeyedStoreIC_Initialize() 2167 ? isolate()->builtins()->KeyedStoreIC_Initialize()
2205 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); 2168 : isolate()->builtins()->KeyedStoreIC_Initialize_Strict();
2206 CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); 2169 CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId());
2207 2170
2208 // If the assignment ends an initialization block, revert to fast case.
2209 if (expr->ends_initialization_block()) {
2210 __ pop(edx);
2211 __ push(eax); // Result of assignment, saved even if not needed.
2212 __ push(edx);
2213 __ CallRuntime(Runtime::kToFastProperties, 1);
2214 __ pop(eax);
2215 }
2216
2217 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); 2171 PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
2218 context()->Plug(eax); 2172 context()->Plug(eax);
2219 } 2173 }
2220 2174
2221 2175
2222 void FullCodeGenerator::VisitProperty(Property* expr) { 2176 void FullCodeGenerator::VisitProperty(Property* expr) {
2223 Comment cmnt(masm_, "[ Property"); 2177 Comment cmnt(masm_, "[ Property");
2224 Expression* key = expr->key(); 2178 Expression* key = expr->key();
2225 2179
2226 if (key->IsPropertyName()) { 2180 if (key->IsPropertyName()) {
(...skipping 2336 matching lines...) Expand 10 before | Expand all | Expand 10 after
4563 *stack_depth = 0; 4517 *stack_depth = 0;
4564 *context_length = 0; 4518 *context_length = 0;
4565 return previous_; 4519 return previous_;
4566 } 4520 }
4567 4521
4568 #undef __ 4522 #undef __
4569 4523
4570 } } // namespace v8::internal 4524 } } // namespace v8::internal
4571 4525
4572 #endif // V8_TARGET_ARCH_IA32 4526 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698