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

Unified Diff: src/ppc/builtins-ppc.cc

Issue 1374423003: Version 4.7.80.4 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.7
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/full-codegen/ppc/full-codegen-ppc.cc ('k') | src/ppc/code-stubs-ppc.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ppc/builtins-ppc.cc
diff --git a/src/ppc/builtins-ppc.cc b/src/ppc/builtins-ppc.cc
index 83d81256f6678d740a8451c97c92c2da58e61846..e08c865e4e92d44b300edd7aa1ede7cdd2107cc0 100644
--- a/src/ppc/builtins-ppc.cc
+++ b/src/ppc/builtins-ppc.cc
@@ -696,8 +696,7 @@ enum IsTagged { kArgcIsSmiTagged, kArgcIsUntaggedInt };
// Clobbers r5; preserves all other registers.
-static void Generate_CheckStackOverflow(MacroAssembler* masm,
- const int calleeOffset, Register argc,
+static void Generate_CheckStackOverflow(MacroAssembler* masm, Register argc,
IsTagged argc_is_tagged) {
// Check the stack for overflow. We are not trying to catch
// interruptions (e.g. debug break and preemption) here, so the "real stack
@@ -718,11 +717,6 @@ static void Generate_CheckStackOverflow(MacroAssembler* masm,
__ bgt(&okay); // Signed comparison.
// Out of stack space.
- __ LoadP(r4, MemOperand(fp, calleeOffset));
- if (argc_is_tagged == kArgcIsUntaggedInt) {
- __ SmiTag(argc);
- }
- __ Push(r4, argc);
__ CallRuntime(Runtime::kThrowStackOverflow, 0);
__ bind(&okay);
@@ -759,12 +753,8 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
__ Push(r4, r5);
// Check if we have enough stack space to push all arguments.
- // The function is the first thing that was pushed above after entering
- // the internal frame.
- const int kFunctionOffset =
- InternalFrameConstants::kCodeOffset - kPointerSize;
// Clobbers r5.
- Generate_CheckStackOverflow(masm, kFunctionOffset, r6, kArgcIsUntaggedInt);
+ Generate_CheckStackOverflow(masm, r6, kArgcIsUntaggedInt);
// Copy arguments to the stack in a loop.
// r4: function
@@ -1349,7 +1339,7 @@ static void Generate_ApplyHelper(MacroAssembler* masm, bool targetIsArgument) {
__ InvokeBuiltin(Context::APPLY_PREPARE_BUILTIN_INDEX, CALL_FUNCTION);
}
- Generate_CheckStackOverflow(masm, kFunctionOffset, r3, kArgcIsSmiTagged);
+ Generate_CheckStackOverflow(masm, r3, kArgcIsSmiTagged);
// Push current limit and index.
const int kIndexOffset = kVectorOffset - (2 * kPointerSize);
@@ -1411,7 +1401,7 @@ static void Generate_ConstructHelper(MacroAssembler* masm) {
__ InvokeBuiltin(Context::REFLECT_CONSTRUCT_PREPARE_BUILTIN_INDEX,
CALL_FUNCTION);
- Generate_CheckStackOverflow(masm, kFunctionOffset, r3, kArgcIsSmiTagged);
+ Generate_CheckStackOverflow(masm, r3, kArgcIsSmiTagged);
// Push current limit and index.
const int kIndexOffset = kVectorOffset - (2 * kPointerSize);
@@ -1605,13 +1595,13 @@ void Builtins::Generate_Call(MacroAssembler* masm) {
// -- r4 : the target to call (can be any Object).
// -----------------------------------
- Label non_smi, non_function;
- __ JumpIfSmi(r4, &non_function);
+ Label non_callable, non_function, non_smi;
+ __ JumpIfSmi(r4, &non_callable);
__ bind(&non_smi);
- __ CompareObjectType(r4, r5, r5, JS_FUNCTION_TYPE);
+ __ CompareObjectType(r4, r7, r8, JS_FUNCTION_TYPE);
__ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET,
eq);
- __ cmpi(r5, Operand(JS_FUNCTION_PROXY_TYPE));
+ __ cmpi(r8, Operand(JS_FUNCTION_PROXY_TYPE));
__ bne(&non_function);
// 1. Call to function proxy.
@@ -1623,28 +1613,24 @@ void Builtins::Generate_Call(MacroAssembler* masm) {
// 2. Call to something else, which might have a [[Call]] internal method (if
// not we raise an exception).
__ bind(&non_function);
- // TODO(bmeurer): I wonder why we prefer to have slow API calls? This could
- // be awesome instead; i.e. a trivial improvement would be to call into the
- // runtime and just deal with the API function there instead of returning a
- // delegate from a runtime call that just jumps back to the runtime once
- // called. Or, bonus points, call directly into the C API function here, as
- // we do in some Crankshaft fast cases.
- // Overwrite the original receiver with the (original) target.
- __ ShiftLeftImm(r5, r3, Operand(kPointerSizeLog2));
- __ StorePX(r4, MemOperand(sp, r5));
+ // Check if target has a [[Call]] internal method.
+ __ lbz(r7, FieldMemOperand(r7, Map::kBitFieldOffset));
+ __ TestBit(r7, Map::kIsCallable, r0);
+ __ beq(&non_callable, cr0);
+ // Overwrite the original receiver the (original) target.
+ __ ShiftLeftImm(r8, r3, Operand(kPointerSizeLog2));
+ __ StorePX(r4, MemOperand(sp, r8));
+ // Let the "call_as_function_delegate" take care of the rest.
+ __ LoadGlobalFunction(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, r4);
+ __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET);
+
+ // 3. Call to something that is not callable.
+ __ bind(&non_callable);
{
- // Determine the delegate for the target (if any).
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
- __ SmiTag(r3);
- __ Push(r3, r4);
- __ CallRuntime(Runtime::kGetFunctionDelegate, 1);
- __ mr(r4, r3);
- __ Pop(r3);
- __ SmiUntag(r3);
+ __ Push(r4);
+ __ CallRuntime(Runtime::kThrowCalledNonCallable, 1);
}
- // The delegate is always a regular function.
- __ AssertFunction(r4);
- __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET);
}
@@ -1672,6 +1658,21 @@ void Builtins::Generate_ConstructFunction(MacroAssembler* masm) {
// static
+void Builtins::Generate_ConstructProxy(MacroAssembler* masm) {
+ // ----------- S t a t e -------------
+ // -- r3 : the number of arguments (not including the receiver)
+ // -- r4 : the constructor to call (checked to be a JSFunctionProxy)
+ // -- r6 : the original constructor (either the same as the constructor or
+ // the JSFunction on which new was invoked initially)
+ // -----------------------------------
+
+ // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies.
+ __ LoadP(r4, FieldMemOperand(r4, JSFunctionProxy::kConstructTrapOffset));
+ __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
+}
+
+
+// static
void Builtins::Generate_Construct(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r3 : the number of arguments (not including the receiver)
@@ -1680,32 +1681,41 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
// the JSFunction on which new was invoked initially)
// -----------------------------------
- Label slow;
- __ JumpIfSmi(r4, &slow);
- __ CompareObjectType(r4, r8, r8, JS_FUNCTION_TYPE);
+ // Check if target has a [[Construct]] internal method.
+ Label non_constructor;
+ __ JumpIfSmi(r4, &non_constructor);
+ __ LoadP(r7, FieldMemOperand(r4, HeapObject::kMapOffset));
+ __ lbz(r5, FieldMemOperand(r7, Map::kBitFieldOffset));
+ __ TestBit(r5, Map::kIsConstructor, r0);
+ __ beq(&non_constructor, cr0);
+
+ // Dispatch based on instance type.
+ __ CompareInstanceType(r7, r8, JS_FUNCTION_TYPE);
__ Jump(masm->isolate()->builtins()->ConstructFunction(),
RelocInfo::CODE_TARGET, eq);
__ cmpi(r8, Operand(JS_FUNCTION_PROXY_TYPE));
- __ bne(&slow);
+ __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET,
+ eq);
- // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies.
- __ LoadP(r4, FieldMemOperand(r4, JSFunctionProxy::kConstructTrapOffset));
- __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
+ // Called Construct on an exotic Object with a [[Construct]] internal method.
+ {
+ // Overwrite the original receiver with the (original) target.
+ __ ShiftLeftImm(r8, r3, Operand(kPointerSizeLog2));
+ __ StorePX(r4, MemOperand(sp, r8));
+ // Let the "call_as_constructor_delegate" take care of the rest.
+ __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r4);
+ __ Jump(masm->isolate()->builtins()->CallFunction(),
+ RelocInfo::CODE_TARGET);
+ }
- __ bind(&slow);
+ // Called Construct on an Object that doesn't have a [[Construct]] internal
+ // method.
+ __ bind(&non_constructor);
{
- // Determine the delegate for the target (if any).
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
- __ SmiTag(r3);
- __ Push(r3, r4);
- __ CallRuntime(Runtime::kGetConstructorDelegate, 1);
- __ mr(r4, r3);
- __ Pop(r3);
- __ SmiUntag(r3);
+ __ Push(r4);
+ __ CallRuntime(Runtime::kThrowCalledNonCallable, 1);
}
- // The delegate is always a regular function.
- __ AssertFunction(r4);
- __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET);
}
« no previous file with comments | « src/full-codegen/ppc/full-codegen-ppc.cc ('k') | src/ppc/code-stubs-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698