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

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

Issue 1159004: Fix issue 656 on x86. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 9 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 4412 matching lines...) Expand 10 before | Expand all | Expand 10 after
4423 4423
4424 Result CodeGenerator::InstantiateFunction( 4424 Result CodeGenerator::InstantiateFunction(
4425 Handle<SharedFunctionInfo> function_info) { 4425 Handle<SharedFunctionInfo> function_info) {
4426 // The inevitable call will sync frame elements to memory anyway, so 4426 // The inevitable call will sync frame elements to memory anyway, so
4427 // we do it eagerly to allow us to push the arguments directly into 4427 // we do it eagerly to allow us to push the arguments directly into
4428 // place. 4428 // place.
4429 frame()->SyncRange(0, frame()->element_count() - 1); 4429 frame()->SyncRange(0, frame()->element_count() - 1);
4430 4430
4431 // Use the fast case closure allocation code that allocates in new 4431 // Use the fast case closure allocation code that allocates in new
4432 // space for nested functions that don't need literals cloning. 4432 // space for nested functions that don't need literals cloning.
4433 // TODO(656): reimplement fast new closure stub 4433 if (scope()->is_function_scope() && function_info->num_literals() == 0) {
4434 if (false && scope()->is_function_scope() &&
4435 function_info->num_literals() == 0) {
4436 FastNewClosureStub stub; 4434 FastNewClosureStub stub;
4437 frame()->EmitPush(Immediate(function_info)); 4435 frame()->EmitPush(Immediate(function_info));
4438 return frame()->CallStub(&stub, 1); 4436 return frame()->CallStub(&stub, 1);
4439 } else { 4437 } else {
4440 // Call the runtime to instantiate the function boilerplate 4438 // Call the runtime to instantiate the function boilerplate
4441 // object. 4439 // object.
4442 frame()->EmitPush(esi); 4440 frame()->EmitPush(esi);
4443 frame()->EmitPush(Immediate(function_info)); 4441 frame()->EmitPush(Immediate(function_info));
4444 return frame()->CallRuntime(Runtime::kNewClosure, 2); 4442 return frame()->CallRuntime(Runtime::kNewClosure, 2);
4445 } 4443 }
(...skipping 3753 matching lines...) Expand 10 before | Expand all | Expand 10 after
8199 } 8197 }
8200 8198
8201 case UNLOADED: 8199 case UNLOADED:
8202 case ILLEGAL: 8200 case ILLEGAL:
8203 UNREACHABLE(); 8201 UNREACHABLE();
8204 } 8202 }
8205 } 8203 }
8206 8204
8207 8205
8208 void FastNewClosureStub::Generate(MacroAssembler* masm) { 8206 void FastNewClosureStub::Generate(MacroAssembler* masm) {
8209 // Clone the boilerplate in new space. Set the context to the 8207 // Create a new closure from the given function info in new
8210 // current context in esi. 8208 // space. Set the context to the current context in esi.
8211 Label gc; 8209 Label gc;
8212 __ AllocateInNewSpace(JSFunction::kSize, eax, ebx, ecx, &gc, TAG_OBJECT); 8210 __ AllocateInNewSpace(JSFunction::kSize, eax, ebx, ecx, &gc, TAG_OBJECT);
8213 8211
8214 // Get the boilerplate function from the stack. 8212 // Get the function info from the stack.
8215 __ mov(edx, Operand(esp, 1 * kPointerSize)); 8213 __ mov(edx, Operand(esp, 1 * kPointerSize));
8216 8214
8217 // Compute the function map in the current global context and set that 8215 // Compute the function map in the current global context and set that
8218 // as the map of the allocated object. 8216 // as the map of the allocated object.
8219 __ mov(ecx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); 8217 __ mov(ecx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)));
8220 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalContextOffset)); 8218 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalContextOffset));
8221 __ mov(ecx, Operand(ecx, Context::SlotOffset(Context::FUNCTION_MAP_INDEX))); 8219 __ mov(ecx, Operand(ecx, Context::SlotOffset(Context::FUNCTION_MAP_INDEX)));
8222 __ mov(FieldOperand(eax, JSObject::kMapOffset), ecx); 8220 __ mov(FieldOperand(eax, JSObject::kMapOffset), ecx);
8223 8221
8224 // Clone the rest of the boilerplate fields. We don't have to update 8222 // Initialize the rest of the function. We don't have to update the
8225 // the write barrier because the allocated object is in new space. 8223 // write barrier because the allocated object is in new space.
8226 for (int offset = kPointerSize; 8224 __ mov(ebx, Immediate(Factory::empty_fixed_array()));
8227 offset < JSFunction::kSize; 8225 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), ebx);
8228 offset += kPointerSize) { 8226 __ mov(FieldOperand(eax, JSObject::kElementsOffset), ebx);
8229 if (offset == JSFunction::kContextOffset) { 8227 __ mov(FieldOperand(eax, JSFunction::kPrototypeOrInitialMapOffset),
8230 __ mov(FieldOperand(eax, offset), esi); 8228 Immediate(Factory::the_hole_value()));
8231 } else { 8229 __ mov(FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset), edx);
8232 __ mov(ebx, FieldOperand(edx, offset)); 8230 __ mov(FieldOperand(eax, JSFunction::kContextOffset), esi);
8233 __ mov(FieldOperand(eax, offset), ebx); 8231 __ mov(FieldOperand(eax, JSFunction::kLiteralsOffset), ebx);
8234 }
8235 }
8236 8232
8237 // Return and remove the on-stack parameter. 8233 // Return and remove the on-stack parameter.
8238 __ ret(1 * kPointerSize); 8234 __ ret(1 * kPointerSize);
8239 8235
8240 // Create a new closure through the slower runtime call. 8236 // Create a new closure through the slower runtime call.
8241 __ bind(&gc); 8237 __ bind(&gc);
8242 __ pop(ecx); // Temporarily remove return address. 8238 __ pop(ecx); // Temporarily remove return address.
8243 __ pop(edx); 8239 __ pop(edx);
8244 __ push(esi); 8240 __ push(esi);
8245 __ push(edx); 8241 __ push(edx);
(...skipping 4031 matching lines...) Expand 10 before | Expand all | Expand 10 after
12277 12273
12278 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 12274 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
12279 // tagged as a small integer. 12275 // tagged as a small integer.
12280 __ bind(&runtime); 12276 __ bind(&runtime);
12281 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 12277 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
12282 } 12278 }
12283 12279
12284 #undef __ 12280 #undef __
12285 12281
12286 } } // namespace v8::internal 12282 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698