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

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

Issue 1533004: Inline %_ArgumentsLength. (Closed)
Patch Set: Created 10 years, 8 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
« no previous file with comments | « src/codegen.cc ('k') | src/x64/codegen-x64.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 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 6210 matching lines...) Expand 10 before | Expand all | Expand 10 after
6221 __ bind(&check_frame_marker); 6221 __ bind(&check_frame_marker);
6222 __ cmp(Operand(fp.reg(), StandardFrameConstants::kMarkerOffset), 6222 __ cmp(Operand(fp.reg(), StandardFrameConstants::kMarkerOffset),
6223 Immediate(Smi::FromInt(StackFrame::CONSTRUCT))); 6223 Immediate(Smi::FromInt(StackFrame::CONSTRUCT)));
6224 fp.Unuse(); 6224 fp.Unuse();
6225 destination()->Split(equal); 6225 destination()->Split(equal);
6226 } 6226 }
6227 6227
6228 6228
6229 void CodeGenerator::GenerateArgumentsLength(ZoneList<Expression*>* args) { 6229 void CodeGenerator::GenerateArgumentsLength(ZoneList<Expression*>* args) {
6230 ASSERT(args->length() == 0); 6230 ASSERT(args->length() == 0);
6231 // ArgumentsAccessStub takes the parameter count as an input argument 6231
6232 // in register eax. Create a constant result for it. 6232 Result fp = allocator_->Allocate();
6233 Result count(Handle<Smi>(Smi::FromInt(scope()->num_parameters()))); 6233 Result result = allocator_->Allocate();
antonm 2010/03/30 13:28:05 shouldn't you Unuse fp and result at the end of th
antonm 2010/03/30 13:28:05 just curious: any chances allocating the single re
Vitaly Repeshko 2010/03/30 13:40:30 ~Result will do it. I think it's only necessary wh
Vitaly Repeshko 2010/03/30 13:40:30 Hard to tell. I can experiment more after this cha
fschneider 2010/03/30 13:44:36 Unuse() is called by the destructor of Result at t
6234 // Call the shared stub to get to the arguments.length. 6234 ASSERT(fp.is_valid() && result.is_valid());
6235 ArgumentsAccessStub stub(ArgumentsAccessStub::READ_LENGTH); 6235
6236 Result result = frame_->CallStub(&stub, &count); 6236 Label exit;
6237
6238 // Get the number of formal parameters.
6239 __ Set(result.reg(), Immediate(Smi::FromInt(scope()->num_parameters())));
6240
6241 // Check if the calling frame is an arguments adaptor frame.
6242 __ mov(fp.reg(), Operand(ebp, StandardFrameConstants::kCallerFPOffset));
6243 __ cmp(Operand(fp.reg(), StandardFrameConstants::kContextOffset),
6244 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
6245 __ j(not_equal, &exit);
6246
6247 // Arguments adaptor case: Read the arguments length from the
6248 // adaptor frame.
6249 __ mov(result.reg(),
6250 Operand(fp.reg(), ArgumentsAdaptorFrameConstants::kLengthOffset));
6251
6252 __ bind(&exit);
6253 result.set_type_info(TypeInfo::Smi());
6254 if (FLAG_debug_code) __ AbortIfNotSmi(result.reg());
antonm 2010/03/30 13:28:05 two questions. 1) why not use cmov still? 2) do w
Vitaly Repeshko 2010/03/30 13:40:30 AFAIK, cmov should be used in totally unpredictabl
6237 frame_->Push(&result); 6255 frame_->Push(&result);
6238 } 6256 }
6239 6257
6240 6258
6241 void CodeGenerator::GenerateClassOf(ZoneList<Expression*>* args) { 6259 void CodeGenerator::GenerateClassOf(ZoneList<Expression*>* args) {
6242 ASSERT(args->length() == 1); 6260 ASSERT(args->length() == 1);
6243 JumpTarget leave, null, function, non_function_constructor; 6261 JumpTarget leave, null, function, non_function_constructor;
6244 Load(args->at(0)); // Load the object. 6262 Load(args->at(0)); // Load the object.
6245 Result obj = frame_->Pop(); 6263 Result obj = frame_->Pop();
6246 obj.ToRegister(); 6264 obj.ToRegister();
(...skipping 4157 matching lines...) Expand 10 before | Expand all | Expand 10 after
10404 break; 10422 break;
10405 case Token::BIT_NOT: 10423 case Token::BIT_NOT:
10406 __ InvokeBuiltin(Builtins::BIT_NOT, JUMP_FUNCTION); 10424 __ InvokeBuiltin(Builtins::BIT_NOT, JUMP_FUNCTION);
10407 break; 10425 break;
10408 default: 10426 default:
10409 UNREACHABLE(); 10427 UNREACHABLE();
10410 } 10428 }
10411 } 10429 }
10412 10430
10413 10431
10414 void ArgumentsAccessStub::GenerateReadLength(MacroAssembler* masm) {
10415 // Check if the calling frame is an arguments adaptor frame.
10416 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
10417 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset));
10418 __ cmp(Operand(ecx), Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
10419
10420 // Arguments adaptor case: Read the arguments length from the
10421 // adaptor frame and return it.
10422 // Otherwise nothing to do: The number of formal parameters has already been
10423 // passed in register eax by calling function. Just return it.
10424 if (CpuFeatures::IsSupported(CMOV)) {
10425 CpuFeatures::Scope use_cmov(CMOV);
10426 __ cmov(equal, eax,
10427 Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset));
10428 } else {
10429 Label exit;
10430 __ j(not_equal, &exit);
10431 __ mov(eax, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset));
10432 __ bind(&exit);
10433 }
10434 __ ret(0);
10435 }
10436
10437
10438 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { 10432 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) {
10439 // The key is in edx and the parameter count is in eax. 10433 // The key is in edx and the parameter count is in eax.
10440 10434
10441 // The displacement is used for skipping the frame pointer on the 10435 // The displacement is used for skipping the frame pointer on the
10442 // stack. It is the offset of the last parameter (if any) relative 10436 // stack. It is the offset of the last parameter (if any) relative
10443 // to the frame pointer. 10437 // to the frame pointer.
10444 static const int kDisplacement = 1 * kPointerSize; 10438 static const int kDisplacement = 1 * kPointerSize;
10445 10439
10446 // Check that the key is a smi. 10440 // Check that the key is a smi.
10447 Label slow; 10441 Label slow;
(...skipping 2153 matching lines...) Expand 10 before | Expand all | Expand 10 after
12601 12595
12602 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 12596 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
12603 // tagged as a small integer. 12597 // tagged as a small integer.
12604 __ bind(&runtime); 12598 __ bind(&runtime);
12605 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 12599 __ TailCallRuntime(Runtime::kStringCompare, 2, 1);
12606 } 12600 }
12607 12601
12608 #undef __ 12602 #undef __
12609 12603
12610 } } // namespace v8::internal 12604 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/codegen.cc ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698