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_H_ 29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define V8_REGEXP_MACRO_ASSEMBLER_H_ 30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 3180d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen#include "ast.h" 3280d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen 33a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace v8 { 34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace internal { 35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstruct DisjunctDecisionRow { 37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block RegExpCharacterClass cc; 38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_match; 39a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 40a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass RegExpMacroAssembler { 43a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // The implementation must be able to handle at least: 45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kMaxRegister = (1 << 16) - 1; 46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kMaxCPOffset = (1 << 15) - 1; 47a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kMinCPOffset = -(1 << 15); 48a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block enum IrregexpImplementation { 49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block kIA32Implementation, 50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block kARMImplementation, 5144f0eee88ff00398ff7f715fab053374d808c90dSteve Block kMIPSImplementation, 52a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block kX64Implementation, 53a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block kBytecodeImplementation 54a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block }; 55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block enum StackCheckFlag { 57a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block kNoStackLimitCheck = false, 58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block kCheckStackLimit = true 59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block }; 60a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 61a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block RegExpMacroAssembler(); 62a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual ~RegExpMacroAssembler(); 63a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // The maximal number of pushes between stack checks. Users must supply 64a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // kCheckStackLimit flag to push operations (instead of kNoStackLimitCheck) 65a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // at least once for every stack_limit() pushes that are executed. 66a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual int stack_limit_slack() = 0; 67a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual bool CanReadUnaligned(); 68a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void AdvanceCurrentPosition(int by) = 0; // Signed cp change. 69a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void AdvanceRegister(int reg, int by) = 0; // r[reg] += by. 70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Continues execution from the position pushed on the top of the backtrack 71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // stack by an earlier PushBacktrack(Label*). 72a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void Backtrack() = 0; 73a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void Bind(Label* label) = 0; 74a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckAtStart(Label* on_at_start) = 0; 75a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Dispatch after looking the current character up in a 2-bits-per-entry 76a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // map. The destinations vector has up to 4 labels. 77b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch virtual void CheckCharacter(unsigned c, Label* on_equal) = 0; 78a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Bitwise and the current character with the given constant and then 79a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // check for a match with c. 80b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch virtual void CheckCharacterAfterAnd(unsigned c, 81b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch unsigned and_with, 82a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_equal) = 0; 83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckCharacterGT(uc16 limit, Label* on_greater) = 0; 84a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckCharacterLT(uc16 limit, Label* on_less) = 0; 85a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Check the current character for a match with a literal string. If we 86a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // fail to match then goto the on_failure label. If check_eos is set then 87a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // the end of input always fails. If check_eos is clear then it is the 88a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // caller's responsibility to ensure that the end of string is not hit. 89a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // If the label is NULL then we should pop a backtrack address off 90a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // the stack and go to that. 91a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckCharacters( 92a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Vector<const uc16> str, 93a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block int cp_offset, 94a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_failure, 95a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block bool check_eos) = 0; 96a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckGreedyLoop(Label* on_tos_equals_current_position) = 0; 97a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckNotAtStart(Label* on_not_at_start) = 0; 98a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckNotBackReference(int start_reg, Label* on_no_match) = 0; 99a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckNotBackReferenceIgnoreCase(int start_reg, 100a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_no_match) = 0; 101a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Check the current character for a match with a literal character. If we 102a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // fail to match then goto the on_failure label. End of input always 103a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // matches. If the label is NULL then we should pop a backtrack address off 104a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // the stack and go to that. 105b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch virtual void CheckNotCharacter(unsigned c, Label* on_not_equal) = 0; 106b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch virtual void CheckNotCharacterAfterAnd(unsigned c, 107b8e0da25ee8efac3bb05cd6b2730aafbd96119f4Ben Murdoch unsigned and_with, 108a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_not_equal) = 0; 109a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Subtract a constant from the current character, then or with the given 110a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // constant and then check for a match with c. 111a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckNotCharacterAfterMinusAnd(uc16 c, 112a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block uc16 minus, 113a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block uc16 and_with, 114a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_not_equal) = 0; 115a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckNotRegistersEqual(int reg1, 116a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block int reg2, 117a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_not_equal) = 0; 118a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 119a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Checks whether the given offset from the current position is before 120a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // the end of the string. May overwrite the current character. 121a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void CheckPosition(int cp_offset, Label* on_outside_input) { 122a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block LoadCurrentCharacter(cp_offset, on_outside_input, true); 123a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block } 124a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Check whether a standard/default character class matches the current 125a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // character. Returns false if the type of special character class does 126a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // not have custom support. 127a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // May clobber the current loaded character. 128a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual bool CheckSpecialCharacterClass(uc16 type, 129a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_no_match) { 130a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return false; 131a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block } 132a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void Fail() = 0; 133053d10c438f14580aaf4ab1b2aad93a5a4fe8b82Steve Block virtual Handle<HeapObject> GetCode(Handle<String> source) = 0; 134a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void GoTo(Label* label) = 0; 135a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Check whether a register is >= a given constant and go to a label if it 136a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // is. Backtracks instead if the label is NULL. 137a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void IfRegisterGE(int reg, int comparand, Label* if_ge) = 0; 138a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Check whether a register is < a given constant and go to a label if it is. 139a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Backtracks instead if the label is NULL. 140a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void IfRegisterLT(int reg, int comparand, Label* if_lt) = 0; 141a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Check whether a register is == to the current position and go to a 142a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // label if it is. 143a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void IfRegisterEqPos(int reg, Label* if_eq) = 0; 144a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual IrregexpImplementation Implementation() = 0; 145a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void LoadCurrentCharacter(int cp_offset, 146a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Label* on_end_of_input, 147a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block bool check_bounds = true, 148a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block int characters = 1) = 0; 149a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void PopCurrentPosition() = 0; 150a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void PopRegister(int register_index) = 0; 151a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Pushes the label on the backtrack stack, so that a following Backtrack 152a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // will go to this label. Always checks the backtrack stack limit. 153a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void PushBacktrack(Label* label) = 0; 154a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void PushCurrentPosition() = 0; 155a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void PushRegister(int register_index, 156a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block StackCheckFlag check_stack_limit) = 0; 157a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void ReadCurrentPositionFromRegister(int reg) = 0; 158a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void ReadStackPointerFromRegister(int reg) = 0; 159f87a203d89e1bbb6708282e0b64dbd13d59b723dBen Murdoch virtual void SetCurrentPositionFromEnd(int by) = 0; 160a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void SetRegister(int register_index, int to) = 0; 161a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void Succeed() = 0; 162a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void WriteCurrentPositionToRegister(int reg, int cp_offset) = 0; 163a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void ClearRegisters(int reg_from, int reg_to) = 0; 164a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual void WriteStackPointerToRegister(int reg) = 0; 165053d10c438f14580aaf4ab1b2aad93a5a4fe8b82Steve Block 166053d10c438f14580aaf4ab1b2aad93a5a4fe8b82Steve Block // Controls the generation of large inlined constants in the code. 167053d10c438f14580aaf4ab1b2aad93a5a4fe8b82Steve Block void set_slow_safe(bool ssc) { slow_safe_compiler_ = ssc; } 168053d10c438f14580aaf4ab1b2aad93a5a4fe8b82Steve Block bool slow_safe() { return slow_safe_compiler_; } 169053d10c438f14580aaf4ab1b2aad93a5a4fe8b82Steve Block 170053d10c438f14580aaf4ab1b2aad93a5a4fe8b82Steve Block private: 171053d10c438f14580aaf4ab1b2aad93a5a4fe8b82Steve Block bool slow_safe_compiler_; 172a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 173a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 174a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1756ded16be15dd865a9b21ea304d5273c8be299c87Steve Block#ifndef V8_INTERPRETED_REGEXP // Avoid compiling unused code. 176a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 177a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass NativeRegExpMacroAssembler: public RegExpMacroAssembler { 178a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 179a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Type of input string to generate code for. 180a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block enum Mode { ASCII = 1, UC16 = 2 }; 181a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 182a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Result of calling generated native RegExp code. 183a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // RETRY: Something significant changed during execution, and the matching 184a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // should be retried from scratch. 185a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // EXCEPTION: Something failed during execution. If no exception has been 186a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // thrown, it's an internal out-of-memory, and the caller should 187a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // throw the exception. 188a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // FAILURE: Matching failed. 189a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // SUCCESS: Matching succeeded, and the output array has been filled with 190a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // capture positions. 191a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block enum Result { RETRY = -2, EXCEPTION = -1, FAILURE = 0, SUCCESS = 1 }; 192a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 193a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block NativeRegExpMacroAssembler(); 194a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual ~NativeRegExpMacroAssembler(); 195a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block virtual bool CanReadUnaligned(); 196a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 197a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static Result Match(Handle<Code> regexp, 198a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Handle<String> subject, 199a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block int* offsets_vector, 200a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block int offsets_vector_length, 20144f0eee88ff00398ff7f715fab053374d808c90dSteve Block int previous_index, 20244f0eee88ff00398ff7f715fab053374d808c90dSteve Block Isolate* isolate); 203a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 204a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Compares two-byte strings case insensitively. 205a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Called from generated RegExp code. 206a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static int CaseInsensitiveCompareUC16(Address byte_offset1, 207a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Address byte_offset2, 20844f0eee88ff00398ff7f715fab053374d808c90dSteve Block size_t byte_length, 20944f0eee88ff00398ff7f715fab053374d808c90dSteve Block Isolate* isolate); 210a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 211a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Called from RegExp if the backtrack stack limit is hit. 212a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Tries to expand the stack. Returns the new stack-pointer if 213a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // successful, and updates the stack_top address, or returns 0 if unable 214a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // to grow the stack. 215a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // This function must not trigger a garbage collection. 21644f0eee88ff00398ff7f715fab053374d808c90dSteve Block static Address GrowStack(Address stack_pointer, Address* stack_top, 21744f0eee88ff00398ff7f715fab053374d808c90dSteve Block Isolate* isolate); 218a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 219a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const byte* StringCharacterPosition(String* subject, int start_index); 220a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 221e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke // Byte map of ASCII characters with a 0xff if the character is a word 222e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke // character (digit, letter or underscore) and 0x00 otherwise. 223e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke // Used by generated RegExp code. 22444f0eee88ff00398ff7f715fab053374d808c90dSteve Block static const byte word_character_map[128]; 225e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke 226e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke static Address word_character_map_address() { 22744f0eee88ff00398ff7f715fab053374d808c90dSteve Block return const_cast<Address>(&word_character_map[0]); 228e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke } 229e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke 230a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static Result Execute(Code* code, 231a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block String* input, 232a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block int start_offset, 233a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block const byte* input_start, 234a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block const byte* input_end, 23544f0eee88ff00398ff7f715fab053374d808c90dSteve Block int* output, 23644f0eee88ff00398ff7f715fab053374d808c90dSteve Block Isolate* isolate); 237a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 238a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 2396ded16be15dd865a9b21ea304d5273c8be299c87Steve Block#endif // V8_INTERPRETED_REGEXP 240a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 241a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} } // namespace v8::internal 242a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 243a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif // V8_REGEXP_MACRO_ASSEMBLER_H_ 244