OLD | NEW |
---|---|
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 4362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4373 | 4373 |
4374 // Leave. | 4374 // Leave. |
4375 leave.Bind(&value); | 4375 leave.Bind(&value); |
4376 frame_->Push(&value); | 4376 frame_->Push(&value); |
4377 } | 4377 } |
4378 | 4378 |
4379 | 4379 |
4380 void CodeGenerator::GenerateArgumentsAccess(ZoneList<Expression*>* args) { | 4380 void CodeGenerator::GenerateArgumentsAccess(ZoneList<Expression*>* args) { |
4381 ASSERT(args->length() == 1); | 4381 ASSERT(args->length() == 1); |
4382 | 4382 |
4383 // Load the key onto the stack and set register eax to the formal | 4383 // Load the key into edx and set eax to the formal parameters count |
4384 // parameters count for the currently executing function. | 4384 // for the currently executing function. |
4385 Load(args->at(0)); | 4385 Load(args->at(0)); |
4386 Result key = frame_->Pop(); | |
4387 key.ToRegister(edx); | |
4388 | |
4386 Result parameters_count = allocator()->Allocate(eax); | 4389 Result parameters_count = allocator()->Allocate(eax); |
4387 ASSERT(parameters_count.is_valid()); | 4390 ASSERT(parameters_count.is_valid()); |
4388 __ Set(parameters_count.reg(), | 4391 __ Set(parameters_count.reg(), |
4389 Immediate(Smi::FromInt(scope_->num_parameters()))); | 4392 Immediate(Smi::FromInt(scope_->num_parameters()))); |
4390 | 4393 |
4391 // Call the shared stub to get to arguments[key]. | 4394 // Call the shared stub to get to arguments[key]. |
4392 ArgumentsAccessStub stub(ArgumentsAccessStub::READ_ELEMENT); | 4395 ArgumentsAccessStub stub(ArgumentsAccessStub::READ_ELEMENT); |
4393 Result result = frame_->CallStub(&stub, ¶meters_count, 0); | 4396 Result result = frame_->CallStub(&stub, ¶meters_count, &key, 0); |
4394 frame_->SetElementAt(0, &result); | 4397 frame_->Push(&result); |
4395 } | 4398 } |
4396 | 4399 |
4397 | 4400 |
4398 void CodeGenerator::GenerateObjectEquals(ZoneList<Expression*>* args) { | 4401 void CodeGenerator::GenerateObjectEquals(ZoneList<Expression*>* args) { |
4399 ASSERT(args->length() == 2); | 4402 ASSERT(args->length() == 2); |
4400 | 4403 |
4401 // Load the two objects into registers and perform the comparison. | 4404 // Load the two objects into registers and perform the comparison. |
4402 Load(args->at(0)); | 4405 Load(args->at(0)); |
4403 Load(args->at(1)); | 4406 Load(args->at(1)); |
4404 Result right = frame_->Pop(); | 4407 Result right = frame_->Pop(); |
(...skipping 1877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6282 | 6285 |
6283 // Arguments adaptor case: Read the arguments length from the | 6286 // Arguments adaptor case: Read the arguments length from the |
6284 // adaptor frame and return it. | 6287 // adaptor frame and return it. |
6285 __ bind(&adaptor); | 6288 __ bind(&adaptor); |
6286 __ mov(eax, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 6289 __ mov(eax, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
6287 __ ret(0); | 6290 __ ret(0); |
6288 } | 6291 } |
6289 | 6292 |
6290 | 6293 |
6291 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { | 6294 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { |
6295 // The key is in edx and the parameter count is in eax. | |
6296 | |
6292 // The displacement is used for skipping the frame pointer on the | 6297 // The displacement is used for skipping the frame pointer on the |
6293 // stack. It is the offset of the last parameter (if any) relative | 6298 // stack. It is the offset of the last parameter (if any) relative |
6294 // to the frame pointer. | 6299 // to the frame pointer. |
6295 static const int kDisplacement = 1 * kPointerSize; | 6300 static const int kDisplacement = 1 * kPointerSize; |
6296 | 6301 |
6297 // Check that the key is a smi. | 6302 // Check that the key is a smi. |
6298 Label slow; | 6303 Label slow; |
6299 __ mov(ebx, Operand(esp, 1 * kPointerSize)); // skip return address | 6304 __ test(edx, Immediate(kSmiTagMask)); |
6300 __ test(ebx, Immediate(kSmiTagMask)); | |
6301 __ j(not_zero, &slow, not_taken); | 6305 __ j(not_zero, &slow, not_taken); |
6302 | 6306 |
6303 // Check if the calling frame is an arguments adaptor frame. | 6307 // Check if the calling frame is an arguments adaptor frame. |
6304 Label adaptor; | 6308 Label adaptor; |
6305 __ mov(edx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 6309 __ mov(ebx, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
6306 __ mov(ecx, Operand(edx, StandardFrameConstants::kContextOffset)); | 6310 __ mov(ecx, Operand(ebx, StandardFrameConstants::kContextOffset)); |
6307 __ cmp(ecx, ArgumentsAdaptorFrame::SENTINEL); | 6311 __ cmp(ecx, ArgumentsAdaptorFrame::SENTINEL); |
6308 __ j(equal, &adaptor); | 6312 __ j(equal, &adaptor); |
6309 | 6313 |
6310 // Check index against formal parameters count limit passed in | 6314 // Check index against formal parameters count limit passed in |
6311 // through register eax. Use unsigned comparison to get negative | 6315 // through register eax. Use unsigned comparison to get negative |
6312 // check for free. | 6316 // check for free. |
6313 __ cmp(ebx, Operand(eax)); | 6317 __ cmp(edx, Operand(eax)); |
6314 __ j(above_equal, &slow, not_taken); | 6318 __ j(above_equal, &slow, not_taken); |
6315 | 6319 |
6316 // Read the argument from the stack and return it. | 6320 // Read the argument from the stack and return it. |
6317 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); // shifting code depends on this | 6321 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); // shifting code depends on this |
6318 __ lea(edx, Operand(ebp, eax, times_2, 0)); | 6322 __ lea(ebx, Operand(ebp, eax, times_2, 0)); |
6319 __ neg(ebx); | 6323 __ neg(edx); |
6320 __ mov(eax, Operand(edx, ebx, times_2, kDisplacement)); | 6324 __ mov(eax, Operand(ebx, edx, times_2, kDisplacement)); |
6321 __ ret(0); | 6325 __ ret(0); |
6322 | 6326 |
6323 // Arguments adaptor case: Check index against actual arguments | 6327 // Arguments adaptor case: Check index against actual arguments |
6324 // limit found in the arguments adaptor frame. Use unsigned | 6328 // limit found in the arguments adaptor frame. Use unsigned |
6325 // comparison to get negative check for free. | 6329 // comparison to get negative check for free. |
6326 __ bind(&adaptor); | 6330 __ bind(&adaptor); |
6327 __ mov(ecx, Operand(edx, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 6331 __ mov(ecx, Operand(ebx, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
6328 __ cmp(ebx, Operand(ecx)); | 6332 __ cmp(edx, Operand(ecx)); |
6329 __ j(above_equal, &slow, not_taken); | 6333 __ j(above_equal, &slow, not_taken); |
6330 | 6334 |
6331 // Read the argument from the stack and return it. | 6335 // Read the argument from the stack and return it. |
6332 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); // shifting code depends on this | 6336 ASSERT(kSmiTagSize == 1 && kSmiTag == 0); // shifting code depends on this |
6333 __ lea(edx, Operand(edx, ecx, times_2, 0)); | 6337 __ lea(ebx, Operand(ebx, ecx, times_2, 0)); |
6334 __ neg(ebx); | 6338 __ neg(edx); |
6335 __ mov(eax, Operand(edx, ebx, times_2, kDisplacement)); | 6339 __ mov(eax, Operand(ebx, edx, times_2, kDisplacement)); |
6336 __ ret(0); | 6340 __ ret(0); |
6337 | 6341 |
6338 // Slow-case: Handle non-smi or out-of-bounds access to arguments | 6342 // Slow-case: Handle non-smi or out-of-bounds access to arguments |
6339 // by calling the runtime system. | 6343 // by calling the runtime system. |
6340 __ bind(&slow); | 6344 __ bind(&slow); |
6345 __ int3(); | |
Kevin Millikin (Chromium)
2009/03/26 12:45:00
Oops. Removed.
| |
6346 __ pop(ebx); // Return address. | |
6347 __ push(edx); | |
6348 __ push(ebx); | |
6341 __ TailCallRuntime(ExternalReference(Runtime::kGetArgumentsProperty), 1); | 6349 __ TailCallRuntime(ExternalReference(Runtime::kGetArgumentsProperty), 1); |
6342 } | 6350 } |
6343 | 6351 |
6344 | 6352 |
6345 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { | 6353 void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) { |
6346 // The displacement is used for skipping the return address and the | 6354 // The displacement is used for skipping the return address and the |
6347 // frame pointer on the stack. It is the offset of the last | 6355 // frame pointer on the stack. It is the offset of the last |
6348 // parameter (if any) relative to the frame pointer. | 6356 // parameter (if any) relative to the frame pointer. |
6349 static const int kDisplacement = 2 * kPointerSize; | 6357 static const int kDisplacement = 2 * kPointerSize; |
6350 | 6358 |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6943 | 6951 |
6944 // Slow-case: Go through the JavaScript implementation. | 6952 // Slow-case: Go through the JavaScript implementation. |
6945 __ bind(&slow); | 6953 __ bind(&slow); |
6946 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 6954 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
6947 } | 6955 } |
6948 | 6956 |
6949 | 6957 |
6950 #undef __ | 6958 #undef __ |
6951 | 6959 |
6952 } } // namespace v8::internal | 6960 } } // namespace v8::internal |
OLD | NEW |