| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 | 38 |
| 39 RegExpMacroAssemblerIrregexp::RegExpMacroAssemblerIrregexp(Vector<byte> buffer) | 39 RegExpMacroAssemblerIrregexp::RegExpMacroAssemblerIrregexp(Vector<byte> buffer) |
| 40 : buffer_(buffer), | 40 : buffer_(buffer), |
| 41 pc_(0), | 41 pc_(0), |
| 42 own_buffer_(false) { | 42 own_buffer_(false) { |
| 43 } | 43 } |
| 44 | 44 |
| 45 | 45 |
| 46 RegExpMacroAssemblerIrregexp::~RegExpMacroAssemblerIrregexp() { | 46 RegExpMacroAssemblerIrregexp::~RegExpMacroAssemblerIrregexp() { |
| 47 if (backtrack_.is_linked()) backtrack_.Unuse(); |
| 47 } | 48 } |
| 48 | 49 |
| 49 | 50 |
| 50 RegExpMacroAssemblerIrregexp::IrregexpImplementation | 51 RegExpMacroAssemblerIrregexp::IrregexpImplementation |
| 51 RegExpMacroAssemblerIrregexp::Implementation() { | 52 RegExpMacroAssemblerIrregexp::Implementation() { |
| 52 return kBytecodeImplementation; | 53 return kBytecodeImplementation; |
| 53 } | 54 } |
| 54 | 55 |
| 55 | 56 |
| 56 void RegExpMacroAssemblerIrregexp::Bind(Label* l) { | 57 void RegExpMacroAssemblerIrregexp::Bind(Label* l) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 190 |
| 190 | 191 |
| 191 void RegExpMacroAssemblerIrregexp::CheckGreedyLoop( | 192 void RegExpMacroAssemblerIrregexp::CheckGreedyLoop( |
| 192 Label* on_tos_equals_current_position) { | 193 Label* on_tos_equals_current_position) { |
| 193 Emit(BC_CHECK_GREEDY); | 194 Emit(BC_CHECK_GREEDY); |
| 194 EmitOrLink(on_tos_equals_current_position); | 195 EmitOrLink(on_tos_equals_current_position); |
| 195 } | 196 } |
| 196 | 197 |
| 197 | 198 |
| 198 void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset, | 199 void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset, |
| 199 Label* on_failure) { | 200 Label* on_failure, |
| 200 Emit(BC_LOAD_CURRENT_CHAR); | 201 bool check_bounds, |
| 202 int characters) { |
| 203 int bytecode; |
| 204 if (check_bounds) { |
| 205 if (characters == 4) { |
| 206 bytecode = BC_LOAD_4_CURRENT_CHARS; |
| 207 } else if (characters == 2) { |
| 208 bytecode = BC_LOAD_2_CURRENT_CHARS; |
| 209 } else { |
| 210 ASSERT(characters == 1); |
| 211 bytecode = BC_LOAD_CURRENT_CHAR; |
| 212 } |
| 213 } else { |
| 214 if (characters == 4) { |
| 215 bytecode = BC_LOAD_4_CURRENT_CHARS_UNCHECKED; |
| 216 } else if (characters == 2) { |
| 217 bytecode = BC_LOAD_2_CURRENT_CHARS_UNCHECKED; |
| 218 } else { |
| 219 ASSERT(characters == 1); |
| 220 bytecode = BC_LOAD_CURRENT_CHAR_UNCHECKED; |
| 221 } |
| 222 } |
| 223 Emit(bytecode); |
| 201 Emit32(cp_offset); | 224 Emit32(cp_offset); |
| 202 EmitOrLink(on_failure); | 225 if (check_bounds) EmitOrLink(on_failure); |
| 203 } | |
| 204 | |
| 205 | |
| 206 void RegExpMacroAssemblerIrregexp::LoadCurrentCharacterUnchecked( | |
| 207 int cp_offset) { | |
| 208 Emit(BC_LOAD_CURRENT_CHAR_UNCHECKED); | |
| 209 Emit32(cp_offset); | |
| 210 } | 226 } |
| 211 | 227 |
| 212 | 228 |
| 213 void RegExpMacroAssemblerIrregexp::CheckCharacterLT(uc16 limit, | 229 void RegExpMacroAssemblerIrregexp::CheckCharacterLT(uc16 limit, |
| 214 Label* on_less) { | 230 Label* on_less) { |
| 215 Emit(BC_CHECK_LT); | 231 Emit(BC_CHECK_LT); |
| 216 Emit16(limit); | 232 Emit16(limit); |
| 217 EmitOrLink(on_less); | 233 EmitOrLink(on_less); |
| 218 } | 234 } |
| 219 | 235 |
| 220 | 236 |
| 221 void RegExpMacroAssemblerIrregexp::CheckCharacterGT(uc16 limit, | 237 void RegExpMacroAssemblerIrregexp::CheckCharacterGT(uc16 limit, |
| 222 Label* on_greater) { | 238 Label* on_greater) { |
| 223 Emit(BC_CHECK_GT); | 239 Emit(BC_CHECK_GT); |
| 224 Emit16(limit); | 240 Emit16(limit); |
| 225 EmitOrLink(on_greater); | 241 EmitOrLink(on_greater); |
| 226 } | 242 } |
| 227 | 243 |
| 228 | 244 |
| 229 void RegExpMacroAssemblerIrregexp::CheckCharacter(uc16 c, Label* on_equal) { | 245 void RegExpMacroAssemblerIrregexp::CheckCharacter(uint32_t c, Label* on_equal) { |
| 230 Emit(BC_CHECK_CHAR); | 246 Emit(BC_CHECK_CHAR); |
| 231 Emit16(c); | 247 Emit32(c); |
| 232 EmitOrLink(on_equal); | 248 EmitOrLink(on_equal); |
| 233 } | 249 } |
| 234 | 250 |
| 235 | 251 |
| 236 void RegExpMacroAssemblerIrregexp::CheckNotAtStart(Label* on_not_at_start) { | 252 void RegExpMacroAssemblerIrregexp::CheckNotAtStart(Label* on_not_at_start) { |
| 237 Emit(BC_CHECK_NOT_AT_START); | 253 Emit(BC_CHECK_NOT_AT_START); |
| 238 EmitOrLink(on_not_at_start); | 254 EmitOrLink(on_not_at_start); |
| 239 } | 255 } |
| 240 | 256 |
| 241 | 257 |
| 242 void RegExpMacroAssemblerIrregexp::CheckNotCharacter(uc16 c, | 258 void RegExpMacroAssemblerIrregexp::CheckNotCharacter(uint32_t c, |
| 243 Label* on_not_equal) { | 259 Label* on_not_equal) { |
| 244 Emit(BC_CHECK_NOT_CHAR); | 260 Emit(BC_CHECK_NOT_CHAR); |
| 245 Emit16(c); | 261 Emit32(c); |
| 246 EmitOrLink(on_not_equal); | 262 EmitOrLink(on_not_equal); |
| 247 } | 263 } |
| 248 | 264 |
| 249 | 265 |
| 250 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterOr( | 266 void RegExpMacroAssemblerIrregexp::CheckCharacterAfterAnd( |
| 251 uc16 c, | 267 uint32_t c, |
| 252 uc16 mask, | 268 uint32_t mask, |
| 269 Label* on_equal) { |
| 270 Emit(BC_AND_CHECK_CHAR); |
| 271 Emit32(c); |
| 272 Emit32(mask); |
| 273 EmitOrLink(on_equal); |
| 274 } |
| 275 |
| 276 |
| 277 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterAnd( |
| 278 uint32_t c, |
| 279 uint32_t mask, |
| 253 Label* on_not_equal) { | 280 Label* on_not_equal) { |
| 254 Emit(BC_OR_CHECK_NOT_CHAR); | 281 Emit(BC_AND_CHECK_NOT_CHAR); |
| 255 Emit16(c); | 282 Emit32(c); |
| 256 Emit16(mask); | 283 Emit32(mask); |
| 257 EmitOrLink(on_not_equal); | 284 EmitOrLink(on_not_equal); |
| 258 } | 285 } |
| 259 | 286 |
| 260 | 287 |
| 261 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterMinusOr( | 288 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterMinusAnd( |
| 262 uc16 c, | 289 uc16 c, |
| 290 uc16 minus, |
| 263 uc16 mask, | 291 uc16 mask, |
| 264 Label* on_not_equal) { | 292 Label* on_not_equal) { |
| 265 Emit(BC_MINUS_OR_CHECK_NOT_CHAR); | 293 Emit(BC_MINUS_AND_CHECK_NOT_CHAR); |
| 266 Emit16(c); | 294 Emit16(c); |
| 295 Emit16(minus); |
| 267 Emit16(mask); | 296 Emit16(mask); |
| 268 EmitOrLink(on_not_equal); | 297 EmitOrLink(on_not_equal); |
| 269 } | 298 } |
| 270 | 299 |
| 271 | 300 |
| 272 void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg, | 301 void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg, |
| 273 Label* on_not_equal) { | 302 Label* on_not_equal) { |
| 274 Emit(BC_CHECK_NOT_BACK_REF); | 303 Emit(BC_CHECK_NOT_BACK_REF); |
| 275 Emit(start_reg); | 304 Emit(start_reg); |
| 276 EmitOrLink(on_not_equal); | 305 EmitOrLink(on_not_equal); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 for (int i = str.length() - 1; i >= 0; i--) { | 366 for (int i = str.length() - 1; i >= 0; i--) { |
| 338 if (check_end_of_string && i == str.length() - 1) { | 367 if (check_end_of_string && i == str.length() - 1) { |
| 339 Emit(BC_LOAD_CURRENT_CHAR); | 368 Emit(BC_LOAD_CURRENT_CHAR); |
| 340 Emit32(cp_offset + i); | 369 Emit32(cp_offset + i); |
| 341 EmitOrLink(on_failure); | 370 EmitOrLink(on_failure); |
| 342 } else { | 371 } else { |
| 343 Emit(BC_LOAD_CURRENT_CHAR_UNCHECKED); | 372 Emit(BC_LOAD_CURRENT_CHAR_UNCHECKED); |
| 344 Emit32(cp_offset + i); | 373 Emit32(cp_offset + i); |
| 345 } | 374 } |
| 346 Emit(BC_CHECK_NOT_CHAR); | 375 Emit(BC_CHECK_NOT_CHAR); |
| 347 Emit16(str[i]); | 376 Emit32(str[i]); |
| 348 EmitOrLink(on_failure); | 377 EmitOrLink(on_failure); |
| 349 } | 378 } |
| 350 } | 379 } |
| 351 | 380 |
| 352 | 381 |
| 353 void RegExpMacroAssemblerIrregexp::IfRegisterLT(int register_index, | 382 void RegExpMacroAssemblerIrregexp::IfRegisterLT(int register_index, |
| 354 int comparand, | 383 int comparand, |
| 355 Label* on_less_than) { | 384 Label* on_less_than) { |
| 356 ASSERT(comparand >= 0 && comparand <= 65535); | 385 ASSERT(comparand >= 0 && comparand <= 65535); |
| 357 Emit(BC_CHECK_REGISTER_LT); | 386 Emit(BC_CHECK_REGISTER_LT); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 buffer_ = Vector<byte>::New(old_buffer.length() * 2); | 426 buffer_ = Vector<byte>::New(old_buffer.length() * 2); |
| 398 own_buffer_ = true; | 427 own_buffer_ = true; |
| 399 memcpy(buffer_.start(), old_buffer.start(), old_buffer.length()); | 428 memcpy(buffer_.start(), old_buffer.start(), old_buffer.length()); |
| 400 if (old_buffer_was_our_own) { | 429 if (old_buffer_was_our_own) { |
| 401 old_buffer.Dispose(); | 430 old_buffer.Dispose(); |
| 402 } | 431 } |
| 403 } | 432 } |
| 404 | 433 |
| 405 | 434 |
| 406 } } // namespace v8::internal | 435 } } // namespace v8::internal |
| OLD | NEW |