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-irregexp.h" |
| 31 #include "assembler-irregexp.h" |
| 32 #include "assembler-irregexp-inl.h" |
| 33 #include "regexp-macro-assembler.h" |
| 34 #include "regexp-macro-assembler-irregexp.h" |
| 35 |
| 36 |
| 37 namespace v8 { namespace internal { |
| 38 |
| 39 |
| 40 RegExpMacroAssemblerIrregexp::~RegExpMacroAssemblerIrregexp() { |
| 41 } |
| 42 |
| 43 |
| 44 RegExpMacroAssemblerIrregexp::IrregexpImplementation |
| 45 RegExpMacroAssemblerIrregexp::Implementation() { |
| 46 return kBytecodeImplementation; |
| 47 } |
| 48 |
| 49 |
| 50 void RegExpMacroAssemblerIrregexp::Bind(Label* l) { |
| 51 assembler_->Bind(l); |
| 52 } |
| 53 |
| 54 |
| 55 void RegExpMacroAssemblerIrregexp::EmitOrLink(Label* l) { |
| 56 assembler_->EmitOrLink(l); |
| 57 } |
| 58 |
| 59 |
| 60 void RegExpMacroAssemblerIrregexp::PopRegister(int register_index) { |
| 61 assembler_->PopRegister(register_index); |
| 62 } |
| 63 |
| 64 |
| 65 void RegExpMacroAssemblerIrregexp::PushRegister(int register_index) { |
| 66 assembler_->PushRegister(register_index); |
| 67 } |
| 68 |
| 69 |
| 70 void RegExpMacroAssemblerIrregexp::WriteCurrentPositionToRegister( |
| 71 int register_index) { |
| 72 assembler_->WriteCurrentPositionToRegister(register_index); |
| 73 } |
| 74 |
| 75 |
| 76 void RegExpMacroAssemblerIrregexp::ReadCurrentPositionFromRegister( |
| 77 int register_index) { |
| 78 assembler_->ReadCurrentPositionFromRegister(register_index); |
| 79 } |
| 80 |
| 81 |
| 82 void RegExpMacroAssemblerIrregexp::WriteStackPointerToRegister( |
| 83 int register_index) { |
| 84 assembler_->WriteStackPointerToRegister(register_index); |
| 85 } |
| 86 |
| 87 |
| 88 void RegExpMacroAssemblerIrregexp::ReadStackPointerFromRegister( |
| 89 int register_index) { |
| 90 assembler_->ReadStackPointerFromRegister(register_index); |
| 91 } |
| 92 |
| 93 |
| 94 void RegExpMacroAssemblerIrregexp::SetRegister(int register_index, int to) { |
| 95 assembler_->SetRegister(register_index, to); |
| 96 } |
| 97 |
| 98 |
| 99 void RegExpMacroAssemblerIrregexp::AdvanceRegister(int register_index, int by) { |
| 100 assembler_->AdvanceRegister(register_index, by); |
| 101 } |
| 102 |
| 103 |
| 104 void RegExpMacroAssemblerIrregexp::PopCurrentPosition() { |
| 105 assembler_->PopCurrentPosition(); |
| 106 } |
| 107 |
| 108 |
| 109 void RegExpMacroAssemblerIrregexp::PushCurrentPosition() { |
| 110 assembler_->PushCurrentPosition(); |
| 111 } |
| 112 |
| 113 |
| 114 void RegExpMacroAssemblerIrregexp::Backtrack() { |
| 115 assembler_->PopBacktrack(); |
| 116 } |
| 117 |
| 118 |
| 119 void RegExpMacroAssemblerIrregexp::GoTo(Label* l) { |
| 120 assembler_->GoTo(l); |
| 121 } |
| 122 |
| 123 |
| 124 void RegExpMacroAssemblerIrregexp::PushBacktrack(Label* l) { |
| 125 assembler_->PushBacktrack(l); |
| 126 } |
| 127 |
| 128 |
| 129 void RegExpMacroAssemblerIrregexp::Succeed() { |
| 130 assembler_->Succeed(); |
| 131 } |
| 132 |
| 133 |
| 134 void RegExpMacroAssemblerIrregexp::Fail() { |
| 135 assembler_->Fail(); |
| 136 } |
| 137 |
| 138 |
| 139 void RegExpMacroAssemblerIrregexp::AdvanceCurrentPosition(int by) { |
| 140 assembler_->AdvanceCP(by); |
| 141 } |
| 142 |
| 143 |
| 144 void RegExpMacroAssemblerIrregexp::CheckCurrentPosition( |
| 145 int register_index, |
| 146 Label* on_equal) { |
| 147 // TODO(erikcorry): Implement. |
| 148 UNREACHABLE(); |
| 149 } |
| 150 |
| 151 |
| 152 void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset, |
| 153 Label* on_failure) { |
| 154 assembler_->LoadCurrentChar(cp_offset, on_failure); |
| 155 } |
| 156 |
| 157 |
| 158 void RegExpMacroAssemblerIrregexp::CheckCharacterLT(uc16 limit, |
| 159 Label* on_less) { |
| 160 assembler_->CheckCharacterLT(limit, on_less); |
| 161 } |
| 162 |
| 163 |
| 164 void RegExpMacroAssemblerIrregexp::CheckCharacterGT(uc16 limit, |
| 165 Label* on_greater) { |
| 166 assembler_->CheckCharacterGT(limit, on_greater); |
| 167 } |
| 168 |
| 169 |
| 170 void RegExpMacroAssemblerIrregexp::CheckCharacter(uc16 c, Label* on_equal) { |
| 171 assembler_->CheckCharacter(c, on_equal); |
| 172 } |
| 173 |
| 174 |
| 175 void RegExpMacroAssemblerIrregexp::CheckNotCharacter(uc16 c, |
| 176 Label* on_not_equal) { |
| 177 assembler_->CheckNotCharacter(c, on_not_equal); |
| 178 } |
| 179 |
| 180 |
| 181 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterOr(uc16 c, |
| 182 uc16 mask, |
| 183 Label* on_not_equal) { |
| 184 assembler_->OrThenCheckNotCharacter(c, mask, on_not_equal); |
| 185 } |
| 186 |
| 187 |
| 188 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterMinusOr( |
| 189 uc16 c, |
| 190 uc16 mask, |
| 191 Label* on_not_equal) { |
| 192 assembler_->MinusOrThenCheckNotCharacter(c, mask, on_not_equal); |
| 193 } |
| 194 |
| 195 |
| 196 void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg, |
| 197 Label* on_not_equal) { |
| 198 assembler_->CheckNotBackReference(start_reg, on_not_equal); |
| 199 } |
| 200 |
| 201 |
| 202 void RegExpMacroAssemblerIrregexp::CheckBitmap(uc16 start, |
| 203 Label* bitmap, |
| 204 Label* on_zero) { |
| 205 assembler_->LookupMap1(start, bitmap, on_zero); |
| 206 } |
| 207 |
| 208 |
| 209 void RegExpMacroAssemblerIrregexp::DispatchHalfNibbleMap( |
| 210 uc16 start, |
| 211 Label* half_nibble_map, |
| 212 const Vector<Label*>& table) { |
| 213 assembler_->LookupMap2(start, half_nibble_map, table); |
| 214 } |
| 215 |
| 216 |
| 217 void RegExpMacroAssemblerIrregexp::DispatchByteMap( |
| 218 uc16 start, |
| 219 Label* byte_map, |
| 220 const Vector<Label*>& table) { |
| 221 assembler_->LookupMap8(start, byte_map, table); |
| 222 } |
| 223 |
| 224 |
| 225 void RegExpMacroAssemblerIrregexp::DispatchHighByteMap( |
| 226 byte start, |
| 227 Label* byte_map, |
| 228 const Vector<Label*>& table) { |
| 229 assembler_->LookupHighMap8(start, byte_map, table); |
| 230 } |
| 231 |
| 232 |
| 233 void RegExpMacroAssemblerIrregexp::CheckCharacters( |
| 234 Vector<const uc16> str, |
| 235 int cp_offset, |
| 236 Label* on_failure) { |
| 237 for (int i = str.length() - 1; i >= 0; i--) { |
| 238 assembler_->LoadCurrentChar(cp_offset + i, on_failure); |
| 239 assembler_->CheckNotCharacter(str[i], on_failure); |
| 240 } |
| 241 } |
| 242 |
| 243 |
| 244 void RegExpMacroAssemblerIrregexp::IfRegisterLT(int register_index, |
| 245 int comparand, |
| 246 Label* if_less_than) { |
| 247 ASSERT(comparand >= 0 && comparand <= 65535); |
| 248 assembler_->CheckRegisterLT(register_index, comparand, if_less_than); |
| 249 } |
| 250 |
| 251 |
| 252 void RegExpMacroAssemblerIrregexp::IfRegisterGE(int register_index, |
| 253 int comparand, |
| 254 Label* if_greater_or_equal) { |
| 255 ASSERT(comparand >= 0 && comparand <= 65535); |
| 256 assembler_->CheckRegisterGE(register_index, comparand, if_greater_or_equal); |
| 257 } |
| 258 |
| 259 |
| 260 Handle<Object> RegExpMacroAssemblerIrregexp::GetCode() { |
| 261 Handle<ByteArray> array = Factory::NewByteArray(assembler_->length()); |
| 262 assembler_->Copy(array->GetDataStartAddress()); |
| 263 return array; |
| 264 } |
| 265 |
| 266 } } // namespace v8::internal |
OLD | NEW |