Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: src/jsregexp.cc

Issue 173567: ARM native regexps. (Closed)
Patch Set: Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "regexp-stack.h" 44 #include "regexp-stack.h"
45 45
46 #ifdef V8_NATIVE_REGEXP 46 #ifdef V8_NATIVE_REGEXP
47 #if V8_TARGET_ARCH_IA32 47 #if V8_TARGET_ARCH_IA32
48 #include "ia32/macro-assembler-ia32.h" 48 #include "ia32/macro-assembler-ia32.h"
49 #include "ia32/regexp-macro-assembler-ia32.h" 49 #include "ia32/regexp-macro-assembler-ia32.h"
50 #elif V8_TARGET_ARCH_X64 50 #elif V8_TARGET_ARCH_X64
51 #include "x64/macro-assembler-x64.h" 51 #include "x64/macro-assembler-x64.h"
52 #include "x64/regexp-macro-assembler-x64.h" 52 #include "x64/regexp-macro-assembler-x64.h"
53 #elif V8_TARGET_ARCH_ARM 53 #elif V8_TARGET_ARCH_ARM
54 #include "arm/macro-assembler-arm.h"
54 #include "arm/regexp-macro-assembler-arm.h" 55 #include "arm/regexp-macro-assembler-arm.h"
55 #else 56 #else
56 #error Unsupported target architecture. 57 #error Unsupported target architecture.
57 #endif 58 #endif
58 #endif 59 #endif
59 60
60 #include "interpreter-irregexp.h" 61 #include "interpreter-irregexp.h"
61 62
62 63
63 namespace v8 { 64 namespace v8 {
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 413 }
413 414
414 last_match_info->EnsureSize(number_of_capture_registers + kLastMatchOverhead); 415 last_match_info->EnsureSize(number_of_capture_registers + kLastMatchOverhead);
415 416
416 Handle<FixedArray> array; 417 Handle<FixedArray> array;
417 418
418 // Dispatch to the correct RegExp implementation. 419 // Dispatch to the correct RegExp implementation.
419 Handle<FixedArray> regexp(FixedArray::cast(jsregexp->data())); 420 Handle<FixedArray> regexp(FixedArray::cast(jsregexp->data()));
420 421
421 #ifdef V8_NATIVE_REGEXP 422 #ifdef V8_NATIVE_REGEXP
422 #ifdef V8_TARGET_ARCH_ARM 423
423 UNIMPLEMENTED();
424 #else // Native regexp supported.
425 OffsetsVector captures(number_of_capture_registers); 424 OffsetsVector captures(number_of_capture_registers);
426 int* captures_vector = captures.vector(); 425 int* captures_vector = captures.vector();
427 NativeRegExpMacroAssembler::Result res; 426 NativeRegExpMacroAssembler::Result res;
428 do { 427 do {
429 bool is_ascii = subject->IsAsciiRepresentation(); 428 bool is_ascii = subject->IsAsciiRepresentation();
430 if (!EnsureCompiledIrregexp(jsregexp, is_ascii)) { 429 if (!EnsureCompiledIrregexp(jsregexp, is_ascii)) {
431 return Handle<Object>::null(); 430 return Handle<Object>::null();
432 } 431 }
433 Handle<Code> code(RegExpImpl::IrregexpNativeCode(*regexp, is_ascii)); 432 Handle<Code> code(RegExpImpl::IrregexpNativeCode(*regexp, is_ascii));
434 res = NativeRegExpMacroAssembler::Match(code, 433 res = NativeRegExpMacroAssembler::Match(code,
(...skipping 13 matching lines...) Expand all
448 447
449 if (res != NativeRegExpMacroAssembler::SUCCESS) return Factory::null_value(); 448 if (res != NativeRegExpMacroAssembler::SUCCESS) return Factory::null_value();
450 449
451 array = Handle<FixedArray>(FixedArray::cast(last_match_info->elements())); 450 array = Handle<FixedArray>(FixedArray::cast(last_match_info->elements()));
452 ASSERT(array->length() >= number_of_capture_registers + kLastMatchOverhead); 451 ASSERT(array->length() >= number_of_capture_registers + kLastMatchOverhead);
453 // The captures come in (start, end+1) pairs. 452 // The captures come in (start, end+1) pairs.
454 for (int i = 0; i < number_of_capture_registers; i += 2) { 453 for (int i = 0; i < number_of_capture_registers; i += 2) {
455 SetCapture(*array, i, captures_vector[i]); 454 SetCapture(*array, i, captures_vector[i]);
456 SetCapture(*array, i + 1, captures_vector[i + 1]); 455 SetCapture(*array, i + 1, captures_vector[i + 1]);
457 } 456 }
458 #endif // Native regexp supported.
459 457
460 #else // ! V8_NATIVE_REGEXP 458 #else // ! V8_NATIVE_REGEXP
459
461 bool is_ascii = subject->IsAsciiRepresentation(); 460 bool is_ascii = subject->IsAsciiRepresentation();
462 if (!EnsureCompiledIrregexp(jsregexp, is_ascii)) { 461 if (!EnsureCompiledIrregexp(jsregexp, is_ascii)) {
463 return Handle<Object>::null(); 462 return Handle<Object>::null();
464 } 463 }
465 // Now that we have done EnsureCompiledIrregexp we can get the number of 464 // Now that we have done EnsureCompiledIrregexp we can get the number of
466 // registers. 465 // registers.
467 int number_of_registers = 466 int number_of_registers =
468 IrregexpNumberOfRegisters(FixedArray::cast(jsregexp->data())); 467 IrregexpNumberOfRegisters(FixedArray::cast(jsregexp->data()));
469 OffsetsVector registers(number_of_registers); 468 OffsetsVector registers(number_of_registers);
470 int* register_vector = registers.vector(); 469 int* register_vector = registers.vector();
471 for (int i = number_of_capture_registers - 1; i >= 0; i--) { 470 for (int i = number_of_capture_registers - 1; i >= 0; i--) {
472 register_vector[i] = -1; 471 register_vector[i] = -1;
473 } 472 }
474 Handle<ByteArray> byte_codes(IrregexpByteCode(*regexp, is_ascii)); 473 Handle<ByteArray> byte_codes(IrregexpByteCode(*regexp, is_ascii));
475 474
476 if (!IrregexpInterpreter::Match(byte_codes, 475 if (!IrregexpInterpreter::Match(byte_codes,
477 subject, 476 subject,
478 register_vector, 477 register_vector,
479 previous_index)) { 478 previous_index)) {
480 return Factory::null_value(); 479 return Factory::null_value();
481 } 480 }
482 481
483 array = Handle<FixedArray>(FixedArray::cast(last_match_info->elements())); 482 array = Handle<FixedArray>(FixedArray::cast(last_match_info->elements()));
484 ASSERT(array->length() >= number_of_capture_registers + kLastMatchOverhead); 483 ASSERT(array->length() >= number_of_capture_registers + kLastMatchOverhead);
485 // The captures come in (start, end+1) pairs. 484 // The captures come in (start, end+1) pairs.
486 for (int i = 0; i < number_of_capture_registers; i += 2) { 485 for (int i = 0; i < number_of_capture_registers; i += 2) {
487 SetCapture(*array, i, register_vector[i]); 486 SetCapture(*array, i, register_vector[i]);
488 SetCapture(*array, i + 1, register_vector[i + 1]); 487 SetCapture(*array, i + 1, register_vector[i + 1]);
489 } 488 }
489
490 #endif // V8_NATIVE_REGEXP 490 #endif // V8_NATIVE_REGEXP
491 491
492 SetLastCaptureCount(*array, number_of_capture_registers); 492 SetLastCaptureCount(*array, number_of_capture_registers);
493 SetLastSubject(*array, *subject); 493 SetLastSubject(*array, *subject);
494 SetLastInput(*array, *subject); 494 SetLastInput(*array, *subject);
495 495
496 return last_match_info; 496 return last_match_info;
497 } 497 }
498 498
499 499
(...skipping 3963 matching lines...) Expand 10 before | Expand all | Expand 10 after
4463 NodeInfo info = *node->info(); 4463 NodeInfo info = *node->info();
4464 4464
4465 // Create the correct assembler for the architecture. 4465 // Create the correct assembler for the architecture.
4466 #ifdef V8_NATIVE_REGEXP 4466 #ifdef V8_NATIVE_REGEXP
4467 // Native regexp implementation. 4467 // Native regexp implementation.
4468 4468
4469 NativeRegExpMacroAssembler::Mode mode = 4469 NativeRegExpMacroAssembler::Mode mode =
4470 is_ascii ? NativeRegExpMacroAssembler::ASCII 4470 is_ascii ? NativeRegExpMacroAssembler::ASCII
4471 : NativeRegExpMacroAssembler::UC16; 4471 : NativeRegExpMacroAssembler::UC16;
4472 4472
4473 #ifdef V8_TARGET_ARCH_IA32 4473 #if V8_TARGET_ARCH_IA32
4474 RegExpMacroAssemblerIA32 macro_assembler(mode, 4474 RegExpMacroAssemblerIA32 macro_assembler(mode, (data->capture_count + 1) * 2);
4475 (data->capture_count + 1) * 2); 4475 #elif V8_TARGET_ARCH_X64
4476 #endif 4476 RegExpMacroAssemblerX64 macro_assembler(mode, (data->capture_count + 1) * 2);
4477 #ifdef V8_TARGET_ARCH_X64 4477 #elif V8_TARGET_ARCH_ARM
4478 RegExpMacroAssemblerX64 macro_assembler(mode, 4478 RegExpMacroAssemblerARM macro_assembler(mode, (data->capture_count + 1) * 2);
4479 (data->capture_count + 1) * 2);
4480 #endif
4481 #ifdef V8_TARGET_ARCH_ARM
4482 UNIMPLEMENTED();
4483 #endif 4479 #endif
4484 4480
4485 #else // ! V8_NATIVE_REGEXP 4481 #else // ! V8_NATIVE_REGEXP
4486 // Interpreted regexp implementation. 4482 // Interpreted regexp implementation.
4487 EmbeddedVector<byte, 1024> codes; 4483 EmbeddedVector<byte, 1024> codes;
4488 RegExpMacroAssemblerIrregexp macro_assembler(codes); 4484 RegExpMacroAssemblerIrregexp macro_assembler(codes);
4489 #endif 4485 #endif
4490 4486
4491 return compiler.Assemble(&macro_assembler, 4487 return compiler.Assemble(&macro_assembler,
4492 node, 4488 node,
4493 data->capture_count, 4489 data->capture_count,
4494 pattern); 4490 pattern);
4495 } 4491 }
4496 4492
4497 }} // namespace v8::internal 4493 }} // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698