1a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Copyright 2008 the V8 project authors. All rights reserved. 2a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Redistribution and use in source and binary forms, with or without 3a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// modification, are permitted provided that the following conditions are 4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// met: 5a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// 6a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// * Redistributions of source code must retain the above copyright 7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// notice, this list of conditions and the following disclaimer. 8a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// * Redistributions in binary form must reproduce the above 9a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// copyright notice, this list of conditions and the following 10a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// disclaimer in the documentation and/or other materials provided 11a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// with the distribution. 12a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// * Neither the name of Google Inc. nor the names of its 13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// contributors may be used to endorse or promote products derived 14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// from this software without specific prior written permission. 15a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// 16a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 28a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifndef V8_REGEXP_MACRO_ASSEMBLER_TRACER_H_ 29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define V8_REGEXP_MACRO_ASSEMBLER_TRACER_H_ 30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace v8 { 32a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace internal { 33a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Decorator on a RegExpMacroAssembler that write all calls. 35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass RegExpMacroAssemblerTracer: public RegExpMacroAssembler { 36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block explicit RegExpMacroAssemblerTracer(RegExpMacroAssembler* assembler); 38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual ~RegExpMacroAssemblerTracer(); 39a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual int stack_limit_slack() { return assembler_->stack_limit_slack(); } 40a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual bool CanReadUnaligned() { return assembler_->CanReadUnaligned(); } 41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void AdvanceCurrentPosition(int by); // Signed cp change. 42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void AdvanceRegister(int reg, int by); // r[reg] += by. 43a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void Backtrack(); 44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void Bind(Label* label); 45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckAtStart(Label* on_at_start); 46b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch virtual void CheckCharacter(unsigned c, Label* on_equal); 47b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch virtual void CheckCharacterAfterAnd(unsigned c, 48b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch unsigned and_with, 49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_equal); 50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckCharacterGT(uc16 limit, Label* on_greater); 51a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckCharacterLT(uc16 limit, Label* on_less); 52a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckCharacters( 53a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Vector<const uc16> str, 54a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block int cp_offset, 55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_failure, 56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block bool check_end_of_string); 57a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckGreedyLoop(Label* on_tos_equals_current_position); 58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckNotAtStart(Label* on_not_at_start); 59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckNotBackReference(int start_reg, Label* on_no_match); 60a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckNotBackReferenceIgnoreCase(int start_reg, 61a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_no_match); 62a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckNotRegistersEqual(int reg1, int reg2, Label* on_not_equal); 63b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch virtual void CheckNotCharacter(unsigned c, Label* on_not_equal); 64b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch virtual void CheckNotCharacterAfterAnd(unsigned c, 65b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch unsigned and_with, 66a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_not_equal); 67a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckNotCharacterAfterMinusAnd(uc16 c, 68a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block uc16 minus, 69a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block uc16 and_with, 70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_not_equal); 71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual bool CheckSpecialCharacterClass(uc16 type, 72a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_no_match); 73a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void Fail(); 74053d10c438f14580aaf4ab1b2aad93a5a4fe8b82Steve Block virtual Handle<HeapObject> GetCode(Handle<String> source); 75a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void GoTo(Label* label); 76a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void IfRegisterGE(int reg, int comparand, Label* if_ge); 77a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void IfRegisterLT(int reg, int comparand, Label* if_lt); 78a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void IfRegisterEqPos(int reg, Label* if_eq); 79a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual IrregexpImplementation Implementation(); 80a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void LoadCurrentCharacter(int cp_offset, 81a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_end_of_input, 82a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block bool check_bounds = true, 83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block int characters = 1); 84a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void PopCurrentPosition(); 85a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void PopRegister(int register_index); 86a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void PushBacktrack(Label* label); 87a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void PushCurrentPosition(); 88a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void PushRegister(int register_index, 89a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block StackCheckFlag check_stack_limit); 90a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void ReadCurrentPositionFromRegister(int reg); 91a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void ReadStackPointerFromRegister(int reg); 92f87a203d89e1bbb6708282e0b64dbd13d59b723dBen Murdoch virtual void SetCurrentPositionFromEnd(int by); 93a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void SetRegister(int register_index, int to); 94a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void Succeed(); 95a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void WriteCurrentPositionToRegister(int reg, int cp_offset); 96a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void ClearRegisters(int reg_from, int reg_to); 97a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void WriteStackPointerToRegister(int reg); 98589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch 99a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block private: 100a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block RegExpMacroAssembler* assembler_; 101a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 102a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 103a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}} // namespace v8::internal 104a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 105a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif // V8_REGEXP_MACRO_ASSEMBLER_TRACER_H_ 106