diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp')
-rw-r--r-- | Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp b/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp index 7f17c0ef1..d7489d31a 100644 --- a/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp +++ b/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2013 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,17 +27,10 @@ #include "BytecodeBasicBlock.h" #include "CodeBlock.h" -#include "JSCInlines.h" #include "PreciseJumpTargets.h" namespace JSC { -void BytecodeBasicBlock::shrinkToFit() -{ - m_bytecodeOffsets.shrinkToFit(); - m_successors.shrinkToFit(); -} - static bool isBranch(OpcodeID opcodeID) { switch (opcodeID) { @@ -58,7 +51,9 @@ static bool isBranch(OpcodeID opcodeID) case op_switch_imm: case op_switch_char: case op_switch_string: - case op_save: + case op_get_pnames: + case op_next_pname: + case op_check_has_instance: return true; default: return false; @@ -79,6 +74,7 @@ static bool isTerminal(OpcodeID opcodeID) { switch (opcodeID) { case op_ret: + case op_ret_object_or_this: case op_end: return true; default: @@ -97,36 +93,38 @@ static bool isThrow(OpcodeID opcodeID) } } -static bool isJumpTarget(OpcodeID opcodeID, const Vector<unsigned, 32>& jumpTargets, unsigned bytecodeOffset) +static bool isJumpTarget(OpcodeID opcodeID, Vector<unsigned, 32>& jumpTargets, unsigned bytecodeOffset) { if (opcodeID == op_catch) return true; - return std::binary_search(jumpTargets.begin(), jumpTargets.end(), bytecodeOffset); + for (unsigned i = 0; i < jumpTargets.size(); i++) { + if (bytecodeOffset == jumpTargets[i]) + return true; + } + return false; } static void linkBlocks(BytecodeBasicBlock* predecessor, BytecodeBasicBlock* successor) { predecessor->addSuccessor(successor); + successor->addPredecessor(predecessor); } -void computeBytecodeBasicBlocks(CodeBlock* codeBlock, Vector<std::unique_ptr<BytecodeBasicBlock>>& basicBlocks) +void computeBytecodeBasicBlocks(CodeBlock* codeBlock, Vector<RefPtr<BytecodeBasicBlock> >& basicBlocks) { Vector<unsigned, 32> jumpTargets; computePreciseJumpTargets(codeBlock, jumpTargets); // Create the entry and exit basic blocks. - basicBlocks.reserveCapacity(jumpTargets.size() + 2); - - auto entry = std::make_unique<BytecodeBasicBlock>(BytecodeBasicBlock::EntryBlock); - auto firstBlock = std::make_unique<BytecodeBasicBlock>(0, 0); - linkBlocks(entry.get(), firstBlock.get()); - - basicBlocks.append(WTFMove(entry)); - BytecodeBasicBlock* current = firstBlock.get(); - basicBlocks.append(WTFMove(firstBlock)); + BytecodeBasicBlock* entry = new BytecodeBasicBlock(BytecodeBasicBlock::EntryBlock); + basicBlocks.append(adoptRef(entry)); + BytecodeBasicBlock* exit = new BytecodeBasicBlock(BytecodeBasicBlock::ExitBlock); - auto exit = std::make_unique<BytecodeBasicBlock>(BytecodeBasicBlock::ExitBlock); + // Find basic block boundaries. + BytecodeBasicBlock* current = new BytecodeBasicBlock(0, 0); + linkBlocks(entry, current); + basicBlocks.append(adoptRef(current)); bool nextInstructionIsLeader = false; @@ -140,9 +138,9 @@ void computeBytecodeBasicBlocks(CodeBlock* codeBlock, Vector<std::unique_ptr<Byt bool createdBlock = false; // If the current bytecode is a jump target, then it's the leader of its own basic block. if (isJumpTarget(opcodeID, jumpTargets, bytecodeOffset) || nextInstructionIsLeader) { - auto newBlock = std::make_unique<BytecodeBasicBlock>(bytecodeOffset, opcodeLength); - current = newBlock.get(); - basicBlocks.append(WTFMove(newBlock)); + BytecodeBasicBlock* block = new BytecodeBasicBlock(bytecodeOffset, opcodeLength); + basicBlocks.append(adoptRef(block)); + current = block; createdBlock = true; nextInstructionIsLeader = false; bytecodeOffset += opcodeLength; @@ -175,7 +173,7 @@ void computeBytecodeBasicBlocks(CodeBlock* codeBlock, Vector<std::unique_ptr<Byt // If we found a terminal bytecode, link to the exit block. if (isTerminal(opcodeID)) { ASSERT(bytecodeOffset + opcodeLength == block->leaderBytecodeOffset() + block->totalBytecodeLength()); - linkBlocks(block, exit.get()); + linkBlocks(block, exit); fallsThrough = false; break; } @@ -188,7 +186,7 @@ void computeBytecodeBasicBlocks(CodeBlock* codeBlock, Vector<std::unique_ptr<Byt HandlerInfo* handler = codeBlock->handlerForBytecodeOffset(bytecodeOffset); fallsThrough = false; if (!handler) { - linkBlocks(block, exit.get()); + linkBlocks(block, exit); break; } for (unsigned i = 0; i < basicBlocks.size(); i++) { @@ -229,10 +227,7 @@ void computeBytecodeBasicBlocks(CodeBlock* codeBlock, Vector<std::unique_ptr<Byt } } - basicBlocks.append(WTFMove(exit)); - - for (auto& basicBlock : basicBlocks) - basicBlock->shrinkToFit(); + basicBlocks.append(adoptRef(exit)); } } // namespace JSC |