| OLD | NEW |
| (Empty) |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | |
| 2 // Redistribution and use in source and binary forms, with or without | |
| 3 // modification, are permitted provided that the following conditions are | |
| 4 // met: | |
| 5 // | |
| 6 // * Redistributions of source code must retain the above copyright | |
| 7 // notice, this list of conditions and the following disclaimer. | |
| 8 // * Redistributions in binary form must reproduce the above | |
| 9 // copyright notice, this list of conditions and the following | |
| 10 // disclaimer in the documentation and/or other materials provided | |
| 11 // with the distribution. | |
| 12 // * Neither the name of Google Inc. nor the names of its | |
| 13 // contributors may be used to endorse or promote products derived | |
| 14 // from this software without specific prior written permission. | |
| 15 // | |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 27 | |
| 28 #include "v8.h" | |
| 29 #include "ast.h" | |
| 30 #include "bytecodes-re2k.h" | |
| 31 #include "assembler-re2k.h" | |
| 32 #include "assembler-re2k-inl.h" | |
| 33 #include "regexp-macro-assembler.h" | |
| 34 #include "regexp-macro-assembler-re2k.h" | |
| 35 | |
| 36 | |
| 37 namespace v8 { namespace internal { | |
| 38 | |
| 39 | |
| 40 RegExpMacroAssemblerRe2k::~RegExpMacroAssemblerRe2k() { | |
| 41 } | |
| 42 | |
| 43 | |
| 44 RegExpMacroAssemblerRe2k::Re2kImplementation | |
| 45 RegExpMacroAssemblerRe2k::Implementation() { | |
| 46 return kBytecodeImplementation; | |
| 47 } | |
| 48 | |
| 49 | |
| 50 void RegExpMacroAssemblerRe2k::Bind(Label* l) { | |
| 51 assembler_->Bind(l); | |
| 52 } | |
| 53 | |
| 54 | |
| 55 void RegExpMacroAssemblerRe2k::EmitOrLink(Label* l) { | |
| 56 assembler_->EmitOrLink(l); | |
| 57 } | |
| 58 | |
| 59 | |
| 60 void RegExpMacroAssemblerRe2k::PopRegister(int register_index) { | |
| 61 assembler_->PopRegister(register_index); | |
| 62 } | |
| 63 | |
| 64 | |
| 65 void RegExpMacroAssemblerRe2k::PushRegister(int register_index) { | |
| 66 assembler_->PushRegister(register_index); | |
| 67 } | |
| 68 | |
| 69 | |
| 70 void RegExpMacroAssemblerRe2k::WriteCurrentPositionToRegister( | |
| 71 int register_index) { | |
| 72 assembler_->WriteCurrentPositionToRegister(register_index); | |
| 73 } | |
| 74 | |
| 75 | |
| 76 void RegExpMacroAssemblerRe2k::ReadCurrentPositionFromRegister( | |
| 77 int register_index) { | |
| 78 assembler_->ReadCurrentPositionFromRegister(register_index); | |
| 79 } | |
| 80 | |
| 81 | |
| 82 void RegExpMacroAssemblerRe2k::WriteStackPointerToRegister(int register_index) { | |
| 83 assembler_->WriteStackPointerToRegister(register_index); | |
| 84 } | |
| 85 | |
| 86 | |
| 87 void RegExpMacroAssemblerRe2k::ReadStackPointerFromRegister( | |
| 88 int register_index) { | |
| 89 assembler_->ReadStackPointerFromRegister(register_index); | |
| 90 } | |
| 91 | |
| 92 | |
| 93 void RegExpMacroAssemblerRe2k::SetRegister(int register_index, int to) { | |
| 94 assembler_->SetRegister(register_index, to); | |
| 95 } | |
| 96 | |
| 97 | |
| 98 void RegExpMacroAssemblerRe2k::AdvanceRegister(int register_index, int by) { | |
| 99 assembler_->AdvanceRegister(register_index, by); | |
| 100 } | |
| 101 | |
| 102 | |
| 103 void RegExpMacroAssemblerRe2k::PopCurrentPosition() { | |
| 104 assembler_->PopCurrentPosition(); | |
| 105 } | |
| 106 | |
| 107 | |
| 108 void RegExpMacroAssemblerRe2k::PushCurrentPosition() { | |
| 109 assembler_->PushCurrentPosition(); | |
| 110 } | |
| 111 | |
| 112 | |
| 113 void RegExpMacroAssemblerRe2k::Backtrack() { | |
| 114 assembler_->PopBacktrack(); | |
| 115 } | |
| 116 | |
| 117 | |
| 118 void RegExpMacroAssemblerRe2k::GoTo(Label* l) { | |
| 119 assembler_->GoTo(l); | |
| 120 } | |
| 121 | |
| 122 | |
| 123 void RegExpMacroAssemblerRe2k::PushBacktrack(Label* l) { | |
| 124 assembler_->PushBacktrack(l); | |
| 125 } | |
| 126 | |
| 127 | |
| 128 void RegExpMacroAssemblerRe2k::Succeed() { | |
| 129 assembler_->Succeed(); | |
| 130 } | |
| 131 | |
| 132 | |
| 133 void RegExpMacroAssemblerRe2k::Fail() { | |
| 134 assembler_->Fail(); | |
| 135 } | |
| 136 | |
| 137 | |
| 138 void RegExpMacroAssemblerRe2k::AdvanceCurrentPosition(int by) { | |
| 139 assembler_->AdvanceCP(by); | |
| 140 } | |
| 141 | |
| 142 | |
| 143 void RegExpMacroAssemblerRe2k::CheckCurrentPosition( | |
| 144 int register_index, | |
| 145 Label* on_equal) { | |
| 146 // TODO(erikcorry): Implement. | |
| 147 UNREACHABLE(); | |
| 148 } | |
| 149 | |
| 150 | |
| 151 void RegExpMacroAssemblerRe2k::LoadCurrentCharacter(int cp_offset, | |
| 152 Label* on_failure) { | |
| 153 assembler_->LoadCurrentChar(cp_offset, on_failure); | |
| 154 } | |
| 155 | |
| 156 | |
| 157 void RegExpMacroAssemblerRe2k::CheckCharacterLT(uc16 limit, Label* on_less) { | |
| 158 assembler_->CheckCharacterLT(limit, on_less); | |
| 159 } | |
| 160 | |
| 161 | |
| 162 void RegExpMacroAssemblerRe2k::CheckCharacterGT(uc16 limit, Label* on_greater) { | |
| 163 assembler_->CheckCharacterGT(limit, on_greater); | |
| 164 } | |
| 165 | |
| 166 | |
| 167 void RegExpMacroAssemblerRe2k::CheckCharacter(uc16 c, Label* on_equal) { | |
| 168 assembler_->CheckCharacter(c, on_equal); | |
| 169 } | |
| 170 | |
| 171 | |
| 172 void RegExpMacroAssemblerRe2k::CheckNotCharacter(uc16 c, Label* on_not_equal) { | |
| 173 assembler_->CheckNotCharacter(c, on_not_equal); | |
| 174 } | |
| 175 | |
| 176 | |
| 177 void RegExpMacroAssemblerRe2k::CheckNotCharacterAfterOr(uc16 c, | |
| 178 uc16 mask, | |
| 179 Label* on_not_equal) { | |
| 180 assembler_->OrThenCheckNotCharacter(c, mask, on_not_equal); | |
| 181 } | |
| 182 | |
| 183 | |
| 184 void RegExpMacroAssemblerRe2k::CheckNotCharacterAfterMinusOr( | |
| 185 uc16 c, | |
| 186 uc16 mask, | |
| 187 Label* on_not_equal) { | |
| 188 assembler_->MinusOrThenCheckNotCharacter(c, mask, on_not_equal); | |
| 189 } | |
| 190 | |
| 191 | |
| 192 void RegExpMacroAssemblerRe2k::CheckNotBackReference(int start_reg, | |
| 193 Label* on_not_equal) { | |
| 194 assembler_->CheckNotBackReference(start_reg, on_not_equal); | |
| 195 } | |
| 196 | |
| 197 | |
| 198 void RegExpMacroAssemblerRe2k::CheckBitmap(uc16 start, | |
| 199 Label* bitmap, | |
| 200 Label* on_zero) { | |
| 201 assembler_->LookupMap1(start, bitmap, on_zero); | |
| 202 } | |
| 203 | |
| 204 | |
| 205 void RegExpMacroAssemblerRe2k::DispatchHalfNibbleMap( | |
| 206 uc16 start, | |
| 207 Label* half_nibble_map, | |
| 208 const Vector<Label*>& table) { | |
| 209 assembler_->LookupMap2(start, half_nibble_map, table); | |
| 210 } | |
| 211 | |
| 212 | |
| 213 void RegExpMacroAssemblerRe2k::DispatchByteMap(uc16 start, | |
| 214 Label* byte_map, | |
| 215 const Vector<Label*>& table) { | |
| 216 assembler_->LookupMap8(start, byte_map, table); | |
| 217 } | |
| 218 | |
| 219 | |
| 220 void RegExpMacroAssemblerRe2k::DispatchHighByteMap( | |
| 221 byte start, | |
| 222 Label* byte_map, | |
| 223 const Vector<Label*>& table) { | |
| 224 assembler_->LookupHighMap8(start, byte_map, table); | |
| 225 } | |
| 226 | |
| 227 | |
| 228 void RegExpMacroAssemblerRe2k::CheckCharacters( | |
| 229 Vector<const uc16> str, | |
| 230 int cp_offset, | |
| 231 Label* on_failure) { | |
| 232 for (int i = str.length() - 1; i >= 0; i--) { | |
| 233 assembler_->LoadCurrentChar(cp_offset + i, on_failure); | |
| 234 assembler_->CheckNotCharacter(str[i], on_failure); | |
| 235 } | |
| 236 } | |
| 237 | |
| 238 | |
| 239 void RegExpMacroAssemblerRe2k::IfRegisterLT(int register_index, | |
| 240 int comparand, | |
| 241 Label* if_less_than) { | |
| 242 ASSERT(comparand >= 0 && comparand <= 65535); | |
| 243 assembler_->CheckRegisterLT(register_index, comparand, if_less_than); | |
| 244 } | |
| 245 | |
| 246 | |
| 247 void RegExpMacroAssemblerRe2k::IfRegisterGE(int register_index, | |
| 248 int comparand, | |
| 249 Label* if_greater_or_equal) { | |
| 250 ASSERT(comparand >= 0 && comparand <= 65535); | |
| 251 assembler_->CheckRegisterGE(register_index, comparand, if_greater_or_equal); | |
| 252 } | |
| 253 | |
| 254 | |
| 255 Handle<Object> RegExpMacroAssemblerRe2k::GetCode() { | |
| 256 Handle<ByteArray> array = Factory::NewByteArray(assembler_->length()); | |
| 257 assembler_->Copy(array->GetDataStartAddress()); | |
| 258 return array; | |
| 259 } | |
| 260 | |
| 261 } } // namespace v8::internal | |
| OLD | NEW |