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

Side by Side Diff: src/mips/lithium-codegen-mips.cc

Issue 100013002: MIPS: Optimize WrapReceiver (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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/mips/lithium-mips.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 3355 matching lines...) Expand 10 before | Expand all | Expand 10 after
3366 __ SmiUntag(result); 3366 __ SmiUntag(result);
3367 3367
3368 // Argument length is in result register. 3368 // Argument length is in result register.
3369 __ bind(&done); 3369 __ bind(&done);
3370 } 3370 }
3371 3371
3372 3372
3373 void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { 3373 void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) {
3374 Register receiver = ToRegister(instr->receiver()); 3374 Register receiver = ToRegister(instr->receiver());
3375 Register function = ToRegister(instr->function()); 3375 Register function = ToRegister(instr->function());
3376 Register result = ToRegister(instr->result());
3376 Register scratch = scratch0(); 3377 Register scratch = scratch0();
3377 3378
3378 // If the receiver is null or undefined, we have to pass the global 3379 // If the receiver is null or undefined, we have to pass the global
3379 // object as a receiver to normal functions. Values have to be 3380 // object as a receiver to normal functions. Values have to be
3380 // passed unchanged to builtins and strict-mode functions. 3381 // passed unchanged to builtins and strict-mode functions.
3381 Label global_object, receiver_ok; 3382 Label global_object, result_in_receiver;
3382 3383
3383 // Do not transform the receiver to object for strict mode 3384 // Do not transform the receiver to object for strict mode
3384 // functions. 3385 // functions.
3385 __ lw(scratch, 3386 __ lw(scratch,
3386 FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset)); 3387 FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset));
3387 __ lw(scratch, 3388 __ lw(scratch,
3388 FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset)); 3389 FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset));
3389 3390
3390 // Do not transform the receiver to object for builtins. 3391 // Do not transform the receiver to object for builtins.
3391 int32_t strict_mode_function_mask = 3392 int32_t strict_mode_function_mask =
3392 1 << (SharedFunctionInfo::kStrictModeFunction + kSmiTagSize); 3393 1 << (SharedFunctionInfo::kStrictModeFunction + kSmiTagSize);
3393 int32_t native_mask = 1 << (SharedFunctionInfo::kNative + kSmiTagSize); 3394 int32_t native_mask = 1 << (SharedFunctionInfo::kNative + kSmiTagSize);
3394 __ And(scratch, scratch, Operand(strict_mode_function_mask | native_mask)); 3395 __ And(scratch, scratch, Operand(strict_mode_function_mask | native_mask));
3395 __ Branch(&receiver_ok, ne, scratch, Operand(zero_reg)); 3396 __ Branch(&result_in_receiver, ne, scratch, Operand(zero_reg));
3396 3397
3397 // Normal function. Replace undefined or null with global receiver. 3398 // Normal function. Replace undefined or null with global receiver.
3398 __ LoadRoot(scratch, Heap::kNullValueRootIndex); 3399 __ LoadRoot(scratch, Heap::kNullValueRootIndex);
3399 __ Branch(&global_object, eq, receiver, Operand(scratch)); 3400 __ Branch(&global_object, eq, receiver, Operand(scratch));
3400 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); 3401 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
3401 __ Branch(&global_object, eq, receiver, Operand(scratch)); 3402 __ Branch(&global_object, eq, receiver, Operand(scratch));
3402 3403
3403 // Deoptimize if the receiver is not a JS object. 3404 // Deoptimize if the receiver is not a JS object.
3404 __ SmiTst(receiver, scratch); 3405 __ SmiTst(receiver, scratch);
3405 DeoptimizeIf(eq, instr->environment(), scratch, Operand(zero_reg)); 3406 DeoptimizeIf(eq, instr->environment(), scratch, Operand(zero_reg));
3406 3407
3407 __ GetObjectType(receiver, scratch, scratch); 3408 __ GetObjectType(receiver, scratch, scratch);
3408 DeoptimizeIf(lt, instr->environment(), 3409 DeoptimizeIf(lt, instr->environment(),
3409 scratch, Operand(FIRST_SPEC_OBJECT_TYPE)); 3410 scratch, Operand(FIRST_SPEC_OBJECT_TYPE));
3410 __ Branch(&receiver_ok); 3411 __ Branch(&result_in_receiver);
3411 3412
3412 __ bind(&global_object); 3413 __ bind(&global_object);
3413 __ lw(receiver, GlobalObjectOperand()); 3414 __ lw(result, GlobalObjectOperand());
3414 __ lw(receiver, 3415 __ lw(result,
3415 FieldMemOperand(receiver, JSGlobalObject::kGlobalReceiverOffset)); 3416 FieldMemOperand(result, JSGlobalObject::kGlobalReceiverOffset));
3416 __ bind(&receiver_ok); 3417 if (result.is(receiver)) {
3418 __ bind(&result_in_receiver);
3419 } else {
3420 Label result_ok;
3421 __ Branch(&result_ok);
3422 __ bind(&result_in_receiver);
3423 __ mov(result, receiver);
3424 __ bind(&result_ok);
3425 }
3417 } 3426 }
3418 3427
3419 3428
3420 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { 3429 void LCodeGen::DoApplyArguments(LApplyArguments* instr) {
3421 Register receiver = ToRegister(instr->receiver()); 3430 Register receiver = ToRegister(instr->receiver());
3422 Register function = ToRegister(instr->function()); 3431 Register function = ToRegister(instr->function());
3423 Register length = ToRegister(instr->length()); 3432 Register length = ToRegister(instr->length());
3424 Register elements = ToRegister(instr->elements()); 3433 Register elements = ToRegister(instr->elements());
3425 Register scratch = scratch0(); 3434 Register scratch = scratch0();
3426 ASSERT(receiver.is(a0)); // Used for parameter count. 3435 ASSERT(receiver.is(a0)); // Used for parameter count.
(...skipping 2442 matching lines...) Expand 10 before | Expand all | Expand 10 after
5869 __ Subu(scratch, result, scratch); 5878 __ Subu(scratch, result, scratch);
5870 __ lw(result, FieldMemOperand(scratch, 5879 __ lw(result, FieldMemOperand(scratch,
5871 FixedArray::kHeaderSize - kPointerSize)); 5880 FixedArray::kHeaderSize - kPointerSize));
5872 __ bind(&done); 5881 __ bind(&done);
5873 } 5882 }
5874 5883
5875 5884
5876 #undef __ 5885 #undef __
5877 5886
5878 } } // namespace v8::internal 5887 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/mips/lithium-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698