mirror of https://github.com/lukechilds/node.git
Ryan Dahl
14 years ago
75 changed files with 4604 additions and 2076 deletions
File diff suppressed because it is too large
@ -0,0 +1,136 @@ |
|||||
|
// Copyright 2010 the V8 project authors. All rights reserved.
|
||||
|
// Redistribution and use in source and binary forms, with or without
|
||||
|
// modification, are permitted provided that the following conditions are
|
||||
|
// met:
|
||||
|
//
|
||||
|
// * Redistributions of source code must retain the above copyright
|
||||
|
// notice, this list of conditions and the following disclaimer.
|
||||
|
// * Redistributions in binary form must reproduce the above
|
||||
|
// copyright notice, this list of conditions and the following
|
||||
|
// disclaimer in the documentation and/or other materials provided
|
||||
|
// with the distribution.
|
||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||
|
// contributors may be used to endorse or promote products derived
|
||||
|
// from this software without specific prior written permission.
|
||||
|
//
|
||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
||||
|
#ifndef V8_GDB_JIT_H_ |
||||
|
#define V8_GDB_JIT_H_ |
||||
|
|
||||
|
//
|
||||
|
// Basic implementation of GDB JIT Interface client.
|
||||
|
// GBD JIT Interface is supported in GDB 7.0 and above.
|
||||
|
// Currently on x64 and ia32 architectures and Linux OS are supported.
|
||||
|
//
|
||||
|
|
||||
|
#ifdef ENABLE_GDB_JIT_INTERFACE |
||||
|
#include "v8.h" |
||||
|
#include "factory.h" |
||||
|
|
||||
|
namespace v8 { |
||||
|
namespace internal { |
||||
|
|
||||
|
#define CODE_TAGS_LIST(V) \ |
||||
|
V(LOAD_IC) \ |
||||
|
V(KEYED_LOAD_IC) \ |
||||
|
V(STORE_IC) \ |
||||
|
V(KEYED_STORE_IC) \ |
||||
|
V(CALL_IC) \ |
||||
|
V(CALL_INITIALIZE) \ |
||||
|
V(CALL_PRE_MONOMORPHIC) \ |
||||
|
V(CALL_NORMAL) \ |
||||
|
V(CALL_MEGAMORPHIC) \ |
||||
|
V(CALL_MISS) \ |
||||
|
V(STUB) \ |
||||
|
V(BUILTIN) \ |
||||
|
V(SCRIPT) \ |
||||
|
V(EVAL) |
||||
|
|
||||
|
class GDBJITLineInfo : public Malloced { |
||||
|
public: |
||||
|
GDBJITLineInfo() |
||||
|
: pc_info_(10) { } |
||||
|
|
||||
|
void SetPosition(intptr_t pc, int pos, bool is_statement) { |
||||
|
AddPCInfo(PCInfo(pc, pos, is_statement)); |
||||
|
} |
||||
|
|
||||
|
struct PCInfo { |
||||
|
PCInfo(intptr_t pc, int pos, bool is_statement) |
||||
|
: pc_(pc), pos_(pos), is_statement_(is_statement) { } |
||||
|
|
||||
|
intptr_t pc_; |
||||
|
int pos_; |
||||
|
bool is_statement_; |
||||
|
}; |
||||
|
|
||||
|
List<PCInfo>* pc_info() { |
||||
|
return &pc_info_; |
||||
|
} |
||||
|
|
||||
|
private: |
||||
|
void AddPCInfo(const PCInfo& pc_info) { |
||||
|
pc_info_.Add(pc_info); |
||||
|
} |
||||
|
|
||||
|
List<PCInfo> pc_info_; |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
class GDBJITInterface: public AllStatic { |
||||
|
public: |
||||
|
enum CodeTag { |
||||
|
#define V(x) x, |
||||
|
CODE_TAGS_LIST(V) |
||||
|
#undef V |
||||
|
TAG_COUNT |
||||
|
}; |
||||
|
|
||||
|
static const char* Tag2String(CodeTag tag) { |
||||
|
switch (tag) { |
||||
|
#define V(x) case x: return #x; |
||||
|
CODE_TAGS_LIST(V) |
||||
|
#undef V |
||||
|
default: |
||||
|
return NULL; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
static void AddCode(const char* name, |
||||
|
Code* code, |
||||
|
Script* script = NULL); |
||||
|
|
||||
|
static void AddCode(Handle<String> name, |
||||
|
Handle<Script> script, |
||||
|
Handle<Code> code); |
||||
|
|
||||
|
static void AddCode(CodeTag tag, String* name, Code* code); |
||||
|
|
||||
|
static void AddCode(CodeTag tag, const char* name, Code* code); |
||||
|
|
||||
|
static void AddCode(CodeTag tag, Code* code); |
||||
|
|
||||
|
static void RemoveCode(Code* code); |
||||
|
|
||||
|
static void RegisterDetailedLineInfo(Code* code, GDBJITLineInfo* line_info); |
||||
|
}; |
||||
|
|
||||
|
#define GDBJIT(action) GDBJITInterface::action |
||||
|
|
||||
|
} } // namespace v8::internal
|
||||
|
#else |
||||
|
#define GDBJIT(action) ((void) 0) |
||||
|
#endif |
||||
|
|
||||
|
#endif |
@ -0,0 +1,461 @@ |
|||||
|
// Copyright 2011 the V8 project authors. All rights reserved.
|
||||
|
// Redistribution and use in source and binary forms, with or without
|
||||
|
// modification, are permitted provided that the following conditions are
|
||||
|
// met:
|
||||
|
//
|
||||
|
// * Redistributions of source code must retain the above copyright
|
||||
|
// notice, this list of conditions and the following disclaimer.
|
||||
|
// * Redistributions in binary form must reproduce the above
|
||||
|
// copyright notice, this list of conditions and the following
|
||||
|
// disclaimer in the documentation and/or other materials provided
|
||||
|
// with the distribution.
|
||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||
|
// contributors may be used to endorse or promote products derived
|
||||
|
// from this software without specific prior written permission.
|
||||
|
//
|
||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
||||
|
#include "ia32/lithium-gap-resolver-ia32.h" |
||||
|
#include "ia32/lithium-codegen-ia32.h" |
||||
|
|
||||
|
namespace v8 { |
||||
|
namespace internal { |
||||
|
|
||||
|
LGapResolver::LGapResolver(LCodeGen* owner) |
||||
|
: cgen_(owner), moves_(32), spilled_register_(-1) { |
||||
|
for (int i = 0; i < Register::kNumAllocatableRegisters; ++i) { |
||||
|
source_uses_[i] = 0; |
||||
|
destination_uses_[i] = 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void LGapResolver::Resolve(LParallelMove* parallel_move) { |
||||
|
ASSERT(HasBeenReset()); |
||||
|
// Build up a worklist of moves.
|
||||
|
BuildInitialMoveList(parallel_move); |
||||
|
|
||||
|
for (int i = 0; i < moves_.length(); ++i) { |
||||
|
LMoveOperands move = moves_[i]; |
||||
|
// Skip constants to perform them last. They don't block other moves
|
||||
|
// and skipping such moves with register destinations keeps those
|
||||
|
// registers free for the whole algorithm.
|
||||
|
if (!move.IsEliminated() && !move.source()->IsConstantOperand()) { |
||||
|
PerformMove(i); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Perform the moves with constant sources.
|
||||
|
for (int i = 0; i < moves_.length(); ++i) { |
||||
|
if (!moves_[i].IsEliminated()) { |
||||
|
ASSERT(moves_[i].source()->IsConstantOperand()); |
||||
|
EmitMove(i); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
Finish(); |
||||
|
ASSERT(HasBeenReset()); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void LGapResolver::BuildInitialMoveList(LParallelMove* parallel_move) { |
||||
|
// Perform a linear sweep of the moves to add them to the initial list of
|
||||
|
// moves to perform, ignoring any move that is redundant (the source is
|
||||
|
// the same as the destination, the destination is ignored and
|
||||
|
// unallocated, or the move was already eliminated).
|
||||
|
const ZoneList<LMoveOperands>* moves = parallel_move->move_operands(); |
||||
|
for (int i = 0; i < moves->length(); ++i) { |
||||
|
LMoveOperands move = moves->at(i); |
||||
|
if (!move.IsRedundant()) AddMove(move); |
||||
|
} |
||||
|
Verify(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void LGapResolver::PerformMove(int index) { |
||||
|
// Each call to this function performs a move and deletes it from the move
|
||||
|
// graph. We first recursively perform any move blocking this one. We
|
||||
|
// mark a move as "pending" on entry to PerformMove in order to detect
|
||||
|
// cycles in the move graph. We use operand swaps to resolve cycles,
|
||||
|
// which means that a call to PerformMove could change any source operand
|
||||
|
// in the move graph.
|
||||
|
|
||||
|
ASSERT(!moves_[index].IsPending()); |
||||
|
ASSERT(!moves_[index].IsRedundant()); |
||||
|
|
||||
|
// Clear this move's destination to indicate a pending move. The actual
|
||||
|
// destination is saved on the side.
|
||||
|
ASSERT(moves_[index].source() != NULL); // Or else it will look eliminated.
|
||||
|
LOperand* destination = moves_[index].destination(); |
||||
|
moves_[index].set_destination(NULL); |
||||
|
|
||||
|
// Perform a depth-first traversal of the move graph to resolve
|
||||
|
// dependencies. Any unperformed, unpending move with a source the same
|
||||
|
// as this one's destination blocks this one so recursively perform all
|
||||
|
// such moves.
|
||||
|
for (int i = 0; i < moves_.length(); ++i) { |
||||
|
LMoveOperands other_move = moves_[i]; |
||||
|
if (other_move.Blocks(destination) && !other_move.IsPending()) { |
||||
|
// Though PerformMove can change any source operand in the move graph,
|
||||
|
// this call cannot create a blocking move via a swap (this loop does
|
||||
|
// not miss any). Assume there is a non-blocking move with source A
|
||||
|
// and this move is blocked on source B and there is a swap of A and
|
||||
|
// B. Then A and B must be involved in the same cycle (or they would
|
||||
|
// not be swapped). Since this move's destination is B and there is
|
||||
|
// only a single incoming edge to an operand, this move must also be
|
||||
|
// involved in the same cycle. In that case, the blocking move will
|
||||
|
// be created but will be "pending" when we return from PerformMove.
|
||||
|
PerformMove(i); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// We are about to resolve this move and don't need it marked as
|
||||
|
// pending, so restore its destination.
|
||||
|
moves_[index].set_destination(destination); |
||||
|
|
||||
|
// This move's source may have changed due to swaps to resolve cycles and
|
||||
|
// so it may now be the last move in the cycle. If so remove it.
|
||||
|
if (moves_[index].source()->Equals(destination)) { |
||||
|
RemoveMove(index); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
// The move may be blocked on a (at most one) pending move, in which case
|
||||
|
// we have a cycle. Search for such a blocking move and perform a swap to
|
||||
|
// resolve it.
|
||||
|
for (int i = 0; i < moves_.length(); ++i) { |
||||
|
LMoveOperands other_move = moves_[i]; |
||||
|
if (other_move.Blocks(destination)) { |
||||
|
ASSERT(other_move.IsPending()); |
||||
|
EmitSwap(index); |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// This move is not blocked.
|
||||
|
EmitMove(index); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void LGapResolver::AddMove(LMoveOperands move) { |
||||
|
LOperand* source = move.source(); |
||||
|
if (source->IsRegister()) ++source_uses_[source->index()]; |
||||
|
|
||||
|
LOperand* destination = move.destination(); |
||||
|
if (destination->IsRegister()) ++destination_uses_[destination->index()]; |
||||
|
|
||||
|
moves_.Add(move); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void LGapResolver::RemoveMove(int index) { |
||||
|
LOperand* source = moves_[index].source(); |
||||
|
if (source->IsRegister()) { |
||||
|
--source_uses_[source->index()]; |
||||
|
ASSERT(source_uses_[source->index()] >= 0); |
||||
|
} |
||||
|
|
||||
|
LOperand* destination = moves_[index].destination(); |
||||
|
if (destination->IsRegister()) { |
||||
|
--destination_uses_[destination->index()]; |
||||
|
ASSERT(destination_uses_[destination->index()] >= 0); |
||||
|
} |
||||
|
|
||||
|
moves_[index].Eliminate(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
int LGapResolver::CountSourceUses(LOperand* operand) { |
||||
|
int count = 0; |
||||
|
for (int i = 0; i < moves_.length(); ++i) { |
||||
|
if (!moves_[i].IsEliminated() && moves_[i].source()->Equals(operand)) { |
||||
|
++count; |
||||
|
} |
||||
|
} |
||||
|
return count; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
Register LGapResolver::GetFreeRegisterNot(Register reg) { |
||||
|
int skip_index = reg.is(no_reg) ? -1 : Register::ToAllocationIndex(reg); |
||||
|
for (int i = 0; i < Register::kNumAllocatableRegisters; ++i) { |
||||
|
if (source_uses_[i] == 0 && destination_uses_[i] > 0 && i != skip_index) { |
||||
|
return Register::FromAllocationIndex(i); |
||||
|
} |
||||
|
} |
||||
|
return no_reg; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
bool LGapResolver::HasBeenReset() { |
||||
|
if (!moves_.is_empty()) return false; |
||||
|
if (spilled_register_ >= 0) return false; |
||||
|
|
||||
|
for (int i = 0; i < Register::kNumAllocatableRegisters; ++i) { |
||||
|
if (source_uses_[i] != 0) return false; |
||||
|
if (destination_uses_[i] != 0) return false; |
||||
|
} |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void LGapResolver::Verify() { |
||||
|
#ifdef ENABLE_SLOW_ASSERTS |
||||
|
// No operand should be the destination for more than one move.
|
||||
|
for (int i = 0; i < moves_.length(); ++i) { |
||||
|
LOperand* destination = moves_[i].destination(); |
||||
|
for (int j = i + 1; j < moves_.length(); ++j) { |
||||
|
SLOW_ASSERT(!destination->Equals(moves_[j].destination())); |
||||
|
} |
||||
|
} |
||||
|
#endif |
||||
|
} |
||||
|
|
||||
|
|
||||
|
#define __ ACCESS_MASM(cgen_->masm()) |
||||
|
|
||||
|
void LGapResolver::Finish() { |
||||
|
if (spilled_register_ >= 0) { |
||||
|
__ pop(Register::FromAllocationIndex(spilled_register_)); |
||||
|
spilled_register_ = -1; |
||||
|
} |
||||
|
moves_.Rewind(0); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void LGapResolver::EnsureRestored(LOperand* operand) { |
||||
|
if (operand->IsRegister() && operand->index() == spilled_register_) { |
||||
|
__ pop(Register::FromAllocationIndex(spilled_register_)); |
||||
|
spilled_register_ = -1; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
Register LGapResolver::EnsureTempRegister() { |
||||
|
// 1. We may have already spilled to create a temp register.
|
||||
|
if (spilled_register_ >= 0) { |
||||
|
return Register::FromAllocationIndex(spilled_register_); |
||||
|
} |
||||
|
|
||||
|
// 2. We may have a free register that we can use without spilling.
|
||||
|
Register free = GetFreeRegisterNot(no_reg); |
||||
|
if (!free.is(no_reg)) return free; |
||||
|
|
||||
|
// 3. Prefer to spill a register that is not used in any remaining move
|
||||
|
// because it will not need to be restored until the end.
|
||||
|
for (int i = 0; i < Register::kNumAllocatableRegisters; ++i) { |
||||
|
if (source_uses_[i] == 0 && destination_uses_[i] == 0) { |
||||
|
Register scratch = Register::FromAllocationIndex(i); |
||||
|
__ push(scratch); |
||||
|
spilled_register_ = i; |
||||
|
return scratch; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 4. Use an arbitrary register. Register 0 is as arbitrary as any other.
|
||||
|
Register scratch = Register::FromAllocationIndex(0); |
||||
|
__ push(scratch); |
||||
|
spilled_register_ = 0; |
||||
|
return scratch; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void LGapResolver::EmitMove(int index) { |
||||
|
LOperand* source = moves_[index].source(); |
||||
|
LOperand* destination = moves_[index].destination(); |
||||
|
EnsureRestored(source); |
||||
|
EnsureRestored(destination); |
||||
|
|
||||
|
// Dispatch on the source and destination operand kinds. Not all
|
||||
|
// combinations are possible.
|
||||
|
if (source->IsRegister()) { |
||||
|
ASSERT(destination->IsRegister() || destination->IsStackSlot()); |
||||
|
Register src = cgen_->ToRegister(source); |
||||
|
Operand dst = cgen_->ToOperand(destination); |
||||
|
__ mov(dst, src); |
||||
|
|
||||
|
} else if (source->IsStackSlot()) { |
||||
|
ASSERT(destination->IsRegister() || destination->IsStackSlot()); |
||||
|
Operand src = cgen_->ToOperand(source); |
||||
|
if (destination->IsRegister()) { |
||||
|
Register dst = cgen_->ToRegister(destination); |
||||
|
__ mov(dst, src); |
||||
|
} else { |
||||
|
// Spill on demand to use a temporary register for memory-to-memory
|
||||
|
// moves.
|
||||
|
Register tmp = EnsureTempRegister(); |
||||
|
Operand dst = cgen_->ToOperand(destination); |
||||
|
__ mov(tmp, src); |
||||
|
__ mov(dst, tmp); |
||||
|
} |
||||
|
|
||||
|
} else if (source->IsConstantOperand()) { |
||||
|
ASSERT(destination->IsRegister() || destination->IsStackSlot()); |
||||
|
Immediate src = cgen_->ToImmediate(source); |
||||
|
Operand dst = cgen_->ToOperand(destination); |
||||
|
__ mov(dst, src); |
||||
|
|
||||
|
} else if (source->IsDoubleRegister()) { |
||||
|
ASSERT(destination->IsDoubleRegister() || |
||||
|
destination->IsDoubleStackSlot()); |
||||
|
XMMRegister src = cgen_->ToDoubleRegister(source); |
||||
|
Operand dst = cgen_->ToOperand(destination); |
||||
|
__ movdbl(dst, src); |
||||
|
|
||||
|
} else if (source->IsDoubleStackSlot()) { |
||||
|
ASSERT(destination->IsDoubleRegister() || |
||||
|
destination->IsDoubleStackSlot()); |
||||
|
Operand src = cgen_->ToOperand(source); |
||||
|
if (destination->IsDoubleRegister()) { |
||||
|
XMMRegister dst = cgen_->ToDoubleRegister(destination); |
||||
|
__ movdbl(dst, src); |
||||
|
} else { |
||||
|
// We rely on having xmm0 available as a fixed scratch register.
|
||||
|
Operand dst = cgen_->ToOperand(destination); |
||||
|
__ movdbl(xmm0, src); |
||||
|
__ movdbl(dst, xmm0); |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
UNREACHABLE(); |
||||
|
} |
||||
|
|
||||
|
RemoveMove(index); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void LGapResolver::EmitSwap(int index) { |
||||
|
LOperand* source = moves_[index].source(); |
||||
|
LOperand* destination = moves_[index].destination(); |
||||
|
EnsureRestored(source); |
||||
|
EnsureRestored(destination); |
||||
|
|
||||
|
// Dispatch on the source and destination operand kinds. Not all
|
||||
|
// combinations are possible.
|
||||
|
if (source->IsRegister() && destination->IsRegister()) { |
||||
|
// Register-register.
|
||||
|
Register src = cgen_->ToRegister(source); |
||||
|
Register dst = cgen_->ToRegister(destination); |
||||
|
__ xchg(dst, src); |
||||
|
|
||||
|
} else if ((source->IsRegister() && destination->IsStackSlot()) || |
||||
|
(source->IsStackSlot() && destination->IsRegister())) { |
||||
|
// Register-memory. Use a free register as a temp if possible. Do not
|
||||
|
// spill on demand because the simple spill implementation cannot avoid
|
||||
|
// spilling src at this point.
|
||||
|
Register tmp = GetFreeRegisterNot(no_reg); |
||||
|
Register reg = |
||||
|
cgen_->ToRegister(source->IsRegister() ? source : destination); |
||||
|
Operand mem = |
||||
|
cgen_->ToOperand(source->IsRegister() ? destination : source); |
||||
|
if (tmp.is(no_reg)) { |
||||
|
__ xor_(reg, mem); |
||||
|
__ xor_(mem, reg); |
||||
|
__ xor_(reg, mem); |
||||
|
} else { |
||||
|
__ mov(tmp, mem); |
||||
|
__ mov(mem, reg); |
||||
|
__ mov(reg, tmp); |
||||
|
} |
||||
|
|
||||
|
} else if (source->IsStackSlot() && destination->IsStackSlot()) { |
||||
|
// Memory-memory. Spill on demand to use a temporary. If there is a
|
||||
|
// free register after that, use it as a second temporary.
|
||||
|
Register tmp0 = EnsureTempRegister(); |
||||
|
Register tmp1 = GetFreeRegisterNot(tmp0); |
||||
|
Operand src = cgen_->ToOperand(source); |
||||
|
Operand dst = cgen_->ToOperand(destination); |
||||
|
if (tmp1.is(no_reg)) { |
||||
|
// Only one temp register available to us.
|
||||
|
__ mov(tmp0, dst); |
||||
|
__ xor_(tmp0, src); |
||||
|
__ xor_(src, tmp0); |
||||
|
__ xor_(tmp0, src); |
||||
|
__ mov(dst, tmp0); |
||||
|
} else { |
||||
|
__ mov(tmp0, dst); |
||||
|
__ mov(tmp1, src); |
||||
|
__ mov(dst, tmp1); |
||||
|
__ mov(src, tmp0); |
||||
|
} |
||||
|
|
||||
|
} else if (source->IsDoubleRegister() || destination->IsDoubleRegister()) { |
||||
|
// XMM register-register or register-memory. We rely on having xmm0
|
||||
|
// available as a fixed scratch register.
|
||||
|
ASSERT(source->IsDoubleRegister() || source->IsDoubleStackSlot()); |
||||
|
ASSERT(destination->IsDoubleRegister() || |
||||
|
destination->IsDoubleStackSlot()); |
||||
|
XMMRegister reg = cgen_->ToDoubleRegister(source->IsDoubleRegister() |
||||
|
? source |
||||
|
: destination); |
||||
|
Operand other = |
||||
|
cgen_->ToOperand(source->IsDoubleRegister() ? destination : source); |
||||
|
__ movdbl(xmm0, other); |
||||
|
__ movdbl(other, reg); |
||||
|
__ movdbl(reg, Operand(xmm0)); |
||||
|
|
||||
|
} else if (source->IsDoubleStackSlot() && destination->IsDoubleStackSlot()) { |
||||
|
// Double-width memory-to-memory. Spill on demand to use a general
|
||||
|
// purpose temporary register and also rely on having xmm0 available as
|
||||
|
// a fixed scratch register.
|
||||
|
Register tmp = EnsureTempRegister(); |
||||
|
Operand src0 = cgen_->ToOperand(source); |
||||
|
Operand src1 = cgen_->HighOperand(source); |
||||
|
Operand dst0 = cgen_->ToOperand(destination); |
||||
|
Operand dst1 = cgen_->HighOperand(destination); |
||||
|
__ movdbl(xmm0, dst0); // Save destination in xmm0.
|
||||
|
__ mov(tmp, src0); // Then use tmp to copy source to destination.
|
||||
|
__ mov(dst0, tmp); |
||||
|
__ mov(tmp, src1); |
||||
|
__ mov(dst1, tmp); |
||||
|
__ movdbl(src0, xmm0); |
||||
|
|
||||
|
} else { |
||||
|
// No other combinations are possible.
|
||||
|
UNREACHABLE(); |
||||
|
} |
||||
|
|
||||
|
// The swap of source and destination has executed a move from source to
|
||||
|
// destination.
|
||||
|
RemoveMove(index); |
||||
|
|
||||
|
// Any unperformed (including pending) move with a source of either
|
||||
|
// this move's source or destination needs to have their source
|
||||
|
// changed to reflect the state of affairs after the swap.
|
||||
|
for (int i = 0; i < moves_.length(); ++i) { |
||||
|
LMoveOperands other_move = moves_[i]; |
||||
|
if (other_move.Blocks(source)) { |
||||
|
moves_[i].set_source(destination); |
||||
|
} else if (other_move.Blocks(destination)) { |
||||
|
moves_[i].set_source(source); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// In addition to swapping the actual uses as sources, we need to update
|
||||
|
// the use counts.
|
||||
|
if (source->IsRegister() && destination->IsRegister()) { |
||||
|
int temp = source_uses_[source->index()]; |
||||
|
source_uses_[source->index()] = source_uses_[destination->index()]; |
||||
|
source_uses_[destination->index()] = temp; |
||||
|
} else if (source->IsRegister()) { |
||||
|
// We don't have use counts for non-register operands like destination.
|
||||
|
// Compute those counts now.
|
||||
|
source_uses_[source->index()] = CountSourceUses(source); |
||||
|
} else if (destination->IsRegister()) { |
||||
|
source_uses_[destination->index()] = CountSourceUses(destination); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#undef __ |
||||
|
|
||||
|
} } // namespace v8::internal
|
@ -0,0 +1,110 @@ |
|||||
|
// Copyright 2011 the V8 project authors. All rights reserved.
|
||||
|
// Redistribution and use in source and binary forms, with or without
|
||||
|
// modification, are permitted provided that the following conditions are
|
||||
|
// met:
|
||||
|
//
|
||||
|
// * Redistributions of source code must retain the above copyright
|
||||
|
// notice, this list of conditions and the following disclaimer.
|
||||
|
// * Redistributions in binary form must reproduce the above
|
||||
|
// copyright notice, this list of conditions and the following
|
||||
|
// disclaimer in the documentation and/or other materials provided
|
||||
|
// with the distribution.
|
||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||
|
// contributors may be used to endorse or promote products derived
|
||||
|
// from this software without specific prior written permission.
|
||||
|
//
|
||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
||||
|
#ifndef V8_IA32_LITHIUM_GAP_RESOLVER_IA32_H_ |
||||
|
#define V8_IA32_LITHIUM_GAP_RESOLVER_IA32_H_ |
||||
|
|
||||
|
#include "v8.h" |
||||
|
|
||||
|
#include "lithium-allocator.h" |
||||
|
|
||||
|
namespace v8 { |
||||
|
namespace internal { |
||||
|
|
||||
|
class LCodeGen; |
||||
|
class LGapResolver; |
||||
|
|
||||
|
class LGapResolver BASE_EMBEDDED { |
||||
|
public: |
||||
|
explicit LGapResolver(LCodeGen* owner); |
||||
|
|
||||
|
// Resolve a set of parallel moves, emitting assembler instructions.
|
||||
|
void Resolve(LParallelMove* parallel_move); |
||||
|
|
||||
|
private: |
||||
|
// Build the initial list of moves.
|
||||
|
void BuildInitialMoveList(LParallelMove* parallel_move); |
||||
|
|
||||
|
// Perform the move at the moves_ index in question (possibly requiring
|
||||
|
// other moves to satisfy dependencies).
|
||||
|
void PerformMove(int index); |
||||
|
|
||||
|
// Emit any code necessary at the end of a gap move.
|
||||
|
void Finish(); |
||||
|
|
||||
|
// Add or delete a move from the move graph without emitting any code.
|
||||
|
// Used to build up the graph and remove trivial moves.
|
||||
|
void AddMove(LMoveOperands move); |
||||
|
void RemoveMove(int index); |
||||
|
|
||||
|
// Report the count of uses of operand as a source in a not-yet-performed
|
||||
|
// move. Used to rebuild use counts.
|
||||
|
int CountSourceUses(LOperand* operand); |
||||
|
|
||||
|
// Emit a move and remove it from the move graph.
|
||||
|
void EmitMove(int index); |
||||
|
|
||||
|
// Execute a move by emitting a swap of two operands. The move from
|
||||
|
// source to destination is removed from the move graph.
|
||||
|
void EmitSwap(int index); |
||||
|
|
||||
|
// Ensure that the given operand is not spilled.
|
||||
|
void EnsureRestored(LOperand* operand); |
||||
|
|
||||
|
// Return a register that can be used as a temp register, spilling
|
||||
|
// something if necessary.
|
||||
|
Register EnsureTempRegister(); |
||||
|
|
||||
|
// Return a known free register different from the given one (which could
|
||||
|
// be no_reg---returning any free register), or no_reg if there is no such
|
||||
|
// register.
|
||||
|
Register GetFreeRegisterNot(Register reg); |
||||
|
|
||||
|
// Verify that the state is the initial one, ready to resolve a single
|
||||
|
// parallel move.
|
||||
|
bool HasBeenReset(); |
||||
|
|
||||
|
// Verify the move list before performing moves.
|
||||
|
void Verify(); |
||||
|
|
||||
|
LCodeGen* cgen_; |
||||
|
|
||||
|
// List of moves not yet resolved.
|
||||
|
ZoneList<LMoveOperands> moves_; |
||||
|
|
||||
|
// Source and destination use counts for the general purpose registers.
|
||||
|
int source_uses_[Register::kNumAllocatableRegisters]; |
||||
|
int destination_uses_[Register::kNumAllocatableRegisters]; |
||||
|
|
||||
|
// If we had to spill on demand, the currently spilled register's
|
||||
|
// allocation index.
|
||||
|
int spilled_register_; |
||||
|
}; |
||||
|
|
||||
|
} } // namespace v8::internal
|
||||
|
|
||||
|
#endif // V8_IA32_LITHIUM_GAP_RESOLVER_IA32_H_
|
File diff suppressed because it is too large
@ -0,0 +1,63 @@ |
|||||
|
// Copyright 2011 the V8 project authors. All rights reserved.
|
||||
|
// Redistribution and use in source and binary forms, with or without
|
||||
|
// modification, are permitted provided that the following conditions are
|
||||
|
// met:
|
||||
|
//
|
||||
|
// * Redistributions of source code must retain the above copyright
|
||||
|
// notice, this list of conditions and the following disclaimer.
|
||||
|
// * Redistributions in binary form must reproduce the above
|
||||
|
// copyright notice, this list of conditions and the following
|
||||
|
// disclaimer in the documentation and/or other materials provided
|
||||
|
// with the distribution.
|
||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||
|
// contributors may be used to endorse or promote products derived
|
||||
|
// from this software without specific prior written permission.
|
||||
|
//
|
||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
||||
|
|
||||
|
#include "v8.h" |
||||
|
#include "inspector.h" |
||||
|
|
||||
|
|
||||
|
namespace v8 { |
||||
|
namespace internal { |
||||
|
|
||||
|
#ifdef INSPECTOR |
||||
|
|
||||
|
//============================================================================
|
||||
|
// The Inspector.
|
||||
|
|
||||
|
void Inspector::DumpObjectType(FILE* out, Object *obj, bool print_more) { |
||||
|
// Dump the object pointer.
|
||||
|
OS::FPrint(out, "%p:", reinterpret_cast<void*>(obj)); |
||||
|
if (obj->IsHeapObject()) { |
||||
|
HeapObject *hobj = HeapObject::cast(obj); |
||||
|
OS::FPrint(out, " size %d :", hobj->Size()); |
||||
|
} |
||||
|
|
||||
|
// Dump each object classification that matches this object.
|
||||
|
#define FOR_EACH_TYPE(type) \ |
||||
|
if (obj->Is##type()) { \ |
||||
|
OS::FPrint(out, " %s", #type); \ |
||||
|
} |
||||
|
OBJECT_TYPE_LIST(FOR_EACH_TYPE) |
||||
|
HEAP_OBJECT_TYPE_LIST(FOR_EACH_TYPE) |
||||
|
#undef FOR_EACH_TYPE |
||||
|
} |
||||
|
|
||||
|
|
||||
|
#endif // INSPECTOR
|
||||
|
|
||||
|
} } // namespace v8::internal
|
||||
|
|
@ -0,0 +1,62 @@ |
|||||
|
// Copyright 2011 the V8 project authors. All rights reserved.
|
||||
|
// Redistribution and use in source and binary forms, with or without
|
||||
|
// modification, are permitted provided that the following conditions are
|
||||
|
// met:
|
||||
|
//
|
||||
|
// * Redistributions of source code must retain the above copyright
|
||||
|
// notice, this list of conditions and the following disclaimer.
|
||||
|
// * Redistributions in binary form must reproduce the above
|
||||
|
// copyright notice, this list of conditions and the following
|
||||
|
// disclaimer in the documentation and/or other materials provided
|
||||
|
// with the distribution.
|
||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||
|
// contributors may be used to endorse or promote products derived
|
||||
|
// from this software without specific prior written permission.
|
||||
|
//
|
||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
||||
|
|
||||
|
#ifndef V8_INSPECTOR_H_ |
||||
|
#define V8_INSPECTOR_H_ |
||||
|
|
||||
|
// Only build this code if we're configured with the INSPECTOR.
|
||||
|
#ifdef INSPECTOR |
||||
|
|
||||
|
#include "v8.h" |
||||
|
|
||||
|
#include "objects.h" |
||||
|
|
||||
|
namespace v8 { |
||||
|
namespace internal { |
||||
|
|
||||
|
class Inspector { |
||||
|
public: |
||||
|
|
||||
|
static void DumpObjectType(FILE* out, Object *obj, bool print_more); |
||||
|
static void DumpObjectType(FILE* out, Object *obj) { |
||||
|
DumpObjectType(out, obj, false); |
||||
|
} |
||||
|
static void DumpObjectType(Object *obj, bool print_more) { |
||||
|
DumpObjectType(stdout, obj, print_more); |
||||
|
} |
||||
|
static void DumpObjectType(Object *obj) { |
||||
|
DumpObjectType(stdout, obj, false); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
} } // namespace v8::internal
|
||||
|
|
||||
|
#endif // INSPECTOR
|
||||
|
|
||||
|
#endif // V8_INSPECTOR_H_
|
||||
|
|
@ -0,0 +1,29 @@ |
|||||
|
Copyright (c) 1994-2006 Sun Microsystems Inc. |
||||
|
All Rights Reserved. |
||||
|
|
||||
|
Redistribution and use in source and binary forms, with or without |
||||
|
modification, are permitted provided that the following conditions are |
||||
|
met: |
||||
|
|
||||
|
- Redistributions of source code must retain the above copyright notice, |
||||
|
this list of conditions and the following disclaimer. |
||||
|
|
||||
|
- Redistribution in binary form must reproduce the above copyright |
||||
|
notice, this list of conditions and the following disclaimer in the |
||||
|
documentation and/or other materials provided with the distribution. |
||||
|
|
||||
|
- Neither the name of Sun Microsystems or the names of contributors may |
||||
|
be used to endorse or promote products derived from this software without |
||||
|
specific prior written permission. |
||||
|
|
||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
||||
|
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
||||
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
@ -0,0 +1,18 @@ |
|||||
|
Name: Strongtalk |
||||
|
URL: http://www.strongtalk.org/ |
||||
|
|
||||
|
Code from the Strongtalk assembler is used with modification in the following |
||||
|
files: |
||||
|
|
||||
|
src/assembler.h |
||||
|
src/assembler.cc |
||||
|
src/arm/assembler-arm.cc |
||||
|
src/arm/assembler-arm.h |
||||
|
src/arm/assembler-arm-inl.h |
||||
|
src/ia32/assembler-ia32.cc |
||||
|
src/ia32/assembler-ia32.h |
||||
|
src/ia32/assembler-ia32-inl.h |
||||
|
src/mips/assembler-mips.cc |
||||
|
src/mips/assembler-mips.h |
||||
|
src/mips/assembler-mips-inl.h |
||||
|
src/x64/assembler-x64.h |
File diff suppressed because it is too large
@ -0,0 +1,61 @@ |
|||||
|
// Copyright 2011 the V8 project authors. All rights reserved.
|
||||
|
// Redistribution and use in source and binary forms, with or without
|
||||
|
// modification, are permitted provided that the following conditions are
|
||||
|
// met:
|
||||
|
//
|
||||
|
// * Redistributions of source code must retain the above copyright
|
||||
|
// notice, this list of conditions and the following disclaimer.
|
||||
|
// * Redistributions in binary form must reproduce the above
|
||||
|
// copyright notice, this list of conditions and the following
|
||||
|
// disclaimer in the documentation and/or other materials provided
|
||||
|
// with the distribution.
|
||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||
|
// contributors may be used to endorse or promote products derived
|
||||
|
// from this software without specific prior written permission.
|
||||
|
//
|
||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
||||
|
// The test verifies that parameters of the outer function are correctly
|
||||
|
// accessible from the inner closure.
|
||||
|
|
||||
|
function runner(f, expected) { |
||||
|
for (var i = 0; i < 10000; i++) { // Loop to trigger optimization.
|
||||
|
assertEquals(expected, f.call(this, 10)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
Function.prototype.bind = function(thisObject) |
||||
|
{ |
||||
|
var func = this; |
||||
|
var args = Array.prototype.slice.call(arguments, 1); |
||||
|
function bound() |
||||
|
{ |
||||
|
// Note outer function parameter access (|thisObject|).
|
||||
|
return func.apply( |
||||
|
thisObject, |
||||
|
args.concat(Array.prototype.slice.call(arguments, 0))); |
||||
|
} |
||||
|
return bound; |
||||
|
} |
||||
|
|
||||
|
function sum(x, y) { |
||||
|
return x + y; |
||||
|
} |
||||
|
|
||||
|
function test(n) { |
||||
|
runner(sum.bind(this, n), n + 10); |
||||
|
} |
||||
|
|
||||
|
test(1); |
||||
|
test(42); |
||||
|
test(239); |
Loading…
Reference in new issue