From a4e969f4965059196ca948db781e52f7cfebf19e Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 24 May 2016 08:28:08 +0000 Subject: webkitgtk-2.12.3 --- .../JavaScriptCore/bytecode/BytecodeBasicBlock.cpp | 57 ++++++++++++---------- 1 file changed, 31 insertions(+), 26 deletions(-) (limited to 'Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp') diff --git a/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp b/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp index d7489d31a..7f17c0ef1 100644 --- a/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp +++ b/Source/JavaScriptCore/bytecode/BytecodeBasicBlock.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 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 @@ -27,10 +27,17 @@ #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) { @@ -51,9 +58,7 @@ static bool isBranch(OpcodeID opcodeID) case op_switch_imm: case op_switch_char: case op_switch_string: - case op_get_pnames: - case op_next_pname: - case op_check_has_instance: + case op_save: return true; default: return false; @@ -74,7 +79,6 @@ static bool isTerminal(OpcodeID opcodeID) { switch (opcodeID) { case op_ret: - case op_ret_object_or_this: case op_end: return true; default: @@ -93,38 +97,36 @@ static bool isThrow(OpcodeID opcodeID) } } -static bool isJumpTarget(OpcodeID opcodeID, Vector& jumpTargets, unsigned bytecodeOffset) +static bool isJumpTarget(OpcodeID opcodeID, const Vector& jumpTargets, unsigned bytecodeOffset) { if (opcodeID == op_catch) return true; - for (unsigned i = 0; i < jumpTargets.size(); i++) { - if (bytecodeOffset == jumpTargets[i]) - return true; - } - return false; + return std::binary_search(jumpTargets.begin(), jumpTargets.end(), bytecodeOffset); } static void linkBlocks(BytecodeBasicBlock* predecessor, BytecodeBasicBlock* successor) { predecessor->addSuccessor(successor); - successor->addPredecessor(predecessor); } -void computeBytecodeBasicBlocks(CodeBlock* codeBlock, Vector >& basicBlocks) +void computeBytecodeBasicBlocks(CodeBlock* codeBlock, Vector>& basicBlocks) { Vector jumpTargets; computePreciseJumpTargets(codeBlock, jumpTargets); // Create the entry and exit basic blocks. - BytecodeBasicBlock* entry = new BytecodeBasicBlock(BytecodeBasicBlock::EntryBlock); - basicBlocks.append(adoptRef(entry)); - BytecodeBasicBlock* exit = new BytecodeBasicBlock(BytecodeBasicBlock::ExitBlock); + basicBlocks.reserveCapacity(jumpTargets.size() + 2); + + auto entry = std::make_unique(BytecodeBasicBlock::EntryBlock); + auto firstBlock = std::make_unique(0, 0); + linkBlocks(entry.get(), firstBlock.get()); + + basicBlocks.append(WTFMove(entry)); + BytecodeBasicBlock* current = firstBlock.get(); + basicBlocks.append(WTFMove(firstBlock)); - // Find basic block boundaries. - BytecodeBasicBlock* current = new BytecodeBasicBlock(0, 0); - linkBlocks(entry, current); - basicBlocks.append(adoptRef(current)); + auto exit = std::make_unique(BytecodeBasicBlock::ExitBlock); bool nextInstructionIsLeader = false; @@ -138,9 +140,9 @@ void computeBytecodeBasicBlocks(CodeBlock* codeBlock, Vector(bytecodeOffset, opcodeLength); + current = newBlock.get(); + basicBlocks.append(WTFMove(newBlock)); createdBlock = true; nextInstructionIsLeader = false; bytecodeOffset += opcodeLength; @@ -173,7 +175,7 @@ void computeBytecodeBasicBlocks(CodeBlock* codeBlock, VectorleaderBytecodeOffset() + block->totalBytecodeLength()); - linkBlocks(block, exit); + linkBlocks(block, exit.get()); fallsThrough = false; break; } @@ -186,7 +188,7 @@ void computeBytecodeBasicBlocks(CodeBlock* codeBlock, VectorhandlerForBytecodeOffset(bytecodeOffset); fallsThrough = false; if (!handler) { - linkBlocks(block, exit); + linkBlocks(block, exit.get()); break; } for (unsigned i = 0; i < basicBlocks.size(); i++) { @@ -227,7 +229,10 @@ void computeBytecodeBasicBlocks(CodeBlock* codeBlock, VectorshrinkToFit(); } } // namespace JSC -- cgit v1.2.1