X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/81345200c95645a1b0d2635520f96ad55dfde63f..ed1e77d3adeb83d26fd1dfb16dd84cabdcefd250:/bytecode/CodeOrigin.h?ds=sidebyside diff --git a/bytecode/CodeOrigin.h b/bytecode/CodeOrigin.h index cffd4eb..d1879a3 100644 --- a/bytecode/CodeOrigin.h +++ b/bytecode/CodeOrigin.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. + * Copyright (C) 2011-2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,7 +28,6 @@ #include "CodeBlockHash.h" #include "CodeSpecializationKind.h" -#include "JSFunction.h" #include "ValueRecovery.h" #include "WriteBarrier.h" #include @@ -118,39 +117,97 @@ private: }; struct InlineCallFrame { + enum Kind { + Call, + Construct, + CallVarargs, + ConstructVarargs, + + // For these, the stackOffset incorporates the argument count plus the true return PC + // slot. + GetterCall, + SetterCall + }; + + static Kind kindFor(CodeSpecializationKind kind) + { + switch (kind) { + case CodeForCall: + return Call; + case CodeForConstruct: + return Construct; + } + RELEASE_ASSERT_NOT_REACHED(); + return Call; + } + + static Kind varargsKindFor(CodeSpecializationKind kind) + { + switch (kind) { + case CodeForCall: + return CallVarargs; + case CodeForConstruct: + return ConstructVarargs; + } + RELEASE_ASSERT_NOT_REACHED(); + return Call; + } + + static CodeSpecializationKind specializationKindFor(Kind kind) + { + switch (kind) { + case Call: + case CallVarargs: + case GetterCall: + case SetterCall: + return CodeForCall; + case Construct: + case ConstructVarargs: + return CodeForConstruct; + } + RELEASE_ASSERT_NOT_REACHED(); + return CodeForCall; + } + + static bool isVarargs(Kind kind) + { + switch (kind) { + case CallVarargs: + case ConstructVarargs: + return true; + default: + return false; + } + } + bool isVarargs() const + { + return isVarargs(static_cast(kind)); + } + Vector arguments; // Includes 'this'. WriteBarrier executable; ValueRecovery calleeRecovery; CodeOrigin caller; - BitVector capturedVars; // Indexed by the machine call frame's variable numbering. - signed stackOffset : 30; - bool isCall : 1; + + signed stackOffset : 28; + unsigned kind : 3; // real type is Kind bool isClosureCall : 1; // If false then we know that callee/scope are constants and the DFG won't treat them as variables, i.e. they have to be recovered manually. - VirtualRegister argumentsRegister; // This is only set if the code uses arguments. The unmodified arguments register follows the unmodifiedArgumentsRegister() convention (see CodeBlock.h). + VirtualRegister argumentCountRegister; // Only set when we inline a varargs call. // There is really no good notion of a "default" set of values for // InlineCallFrame's fields. This constructor is here just to reduce confusion if // we forgot to initialize explicitly. InlineCallFrame() : stackOffset(0) - , isCall(false) + , kind(Call) , isClosureCall(false) { } - CodeSpecializationKind specializationKind() const { return specializationFromIsCall(isCall); } - - JSFunction* calleeConstant() const - { - if (calleeRecovery.isConstant()) - return jsCast(calleeRecovery.constant()); - return 0; - } + CodeSpecializationKind specializationKind() const { return specializationKindFor(static_cast(kind)); } - void visitAggregate(SlotVisitor& visitor) - { - visitor.append(&executable); - } + JSFunction* calleeConstant() const; + void visitAggregate(SlotVisitor&); // Get the callee given a machine call frame to which this InlineCallFrame belongs. JSFunction* calleeForCallFrame(ExecState*) const; @@ -161,6 +218,12 @@ struct InlineCallFrame { CodeBlock* baselineCodeBlock() const; + void setStackOffset(signed offset) + { + stackOffset = offset; + RELEASE_ASSERT(static_cast(stackOffset) == offset); + } + ptrdiff_t callerFrameOffset() const { return stackOffset * sizeof(Register) + CallFrame::callerFrameOffset(); } ptrdiff_t returnPCOffset() const { return stackOffset * sizeof(Register) + CallFrame::returnPCOffset(); } @@ -214,6 +277,8 @@ struct CodeOriginApproximateHash { namespace WTF { +void printInternal(PrintStream&, JSC::InlineCallFrame::Kind); + template struct DefaultHash; template<> struct DefaultHash { typedef JSC::CodeOriginHash Hash;