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

Side by Side Diff: src/jsregexp.cc

Issue 99355: Introduce processor detection in globals.h, instead of from the build system. (Closed)
Patch Set: Guard 64-bit literals around 64-bit. Switch to long. Created 11 years, 7 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
« no previous file with comments | « src/jsregexp.h ('k') | src/macro-assembler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 24 matching lines...) Expand all
35 #include "runtime.h" 35 #include "runtime.h"
36 #include "top.h" 36 #include "top.h"
37 #include "compilation-cache.h" 37 #include "compilation-cache.h"
38 #include "string-stream.h" 38 #include "string-stream.h"
39 #include "parser.h" 39 #include "parser.h"
40 #include "regexp-macro-assembler.h" 40 #include "regexp-macro-assembler.h"
41 #include "regexp-macro-assembler-tracer.h" 41 #include "regexp-macro-assembler-tracer.h"
42 #include "regexp-macro-assembler-irregexp.h" 42 #include "regexp-macro-assembler-irregexp.h"
43 #include "regexp-stack.h" 43 #include "regexp-stack.h"
44 44
45 #ifdef V8_ARCH_ARM 45 #ifdef V8_TARGET_ARCH_IA32
46 #include "ia32/macro-assembler-ia32.h"
47 #include "ia32/regexp-macro-assembler-ia32.h"
48 #elif V8_TARGET_ARCH_X64
49 #include "x64/macro-assembler-x64.h"
50 #include "x64/regexp-macro-assembler-x64.h"
51 #elif V8_TARGET_ARCH_ARM
46 #include "arm/regexp-macro-assembler-arm.h" 52 #include "arm/regexp-macro-assembler-arm.h"
47 #endif 53 #endif
48 54
49 #ifdef V8_ARCH_X64
50 #include "x64/macro-assembler-x64.h"
51 #include "x64/regexp-macro-assembler-x64.h"
52 #endif
53
54 #ifdef V8_ARCH_IA32
55 #include "ia32/macro-assembler-ia32.h"
56 #include "ia32/regexp-macro-assembler-ia32.h"
57 #endif
58
59 #include "interpreter-irregexp.h" 55 #include "interpreter-irregexp.h"
60 56
61 57
62 namespace v8 { namespace internal { 58 namespace v8 { namespace internal {
63 59
64 60
65 Handle<Object> RegExpImpl::CreateRegExpLiteral(Handle<JSFunction> constructor, 61 Handle<Object> RegExpImpl::CreateRegExpLiteral(Handle<JSFunction> constructor,
66 Handle<String> pattern, 62 Handle<String> pattern,
67 Handle<String> flags, 63 Handle<String> flags,
68 bool* has_pending_exception) { 64 bool* has_pending_exception) {
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 last_match_info->EnsureSize(number_of_capture_registers + kLastMatchOverhead); 420 last_match_info->EnsureSize(number_of_capture_registers + kLastMatchOverhead);
425 421
426 int* offsets_vector = offsets.vector(); 422 int* offsets_vector = offsets.vector();
427 bool rc; 423 bool rc;
428 424
429 // Dispatch to the correct RegExp implementation. 425 // Dispatch to the correct RegExp implementation.
430 426
431 Handle<String> original_subject = subject; 427 Handle<String> original_subject = subject;
432 Handle<FixedArray> regexp(FixedArray::cast(jsregexp->data())); 428 Handle<FixedArray> regexp(FixedArray::cast(jsregexp->data()));
433 if (UseNativeRegexp()) { 429 if (UseNativeRegexp()) {
434 #ifdef V8_ARCH_ARM 430 #if V8_TARGET_ARCH_IA32
435 UNREACHABLE();
436 #endif
437 #ifdef V8_ARCH_X64
438 UNIMPLEMENTED();
439 #endif
440 #ifdef V8_ARCH_IA32
441 RegExpMacroAssemblerIA32::Result res; 431 RegExpMacroAssemblerIA32::Result res;
442 do { 432 do {
443 bool is_ascii = subject->IsAsciiRepresentation(); 433 bool is_ascii = subject->IsAsciiRepresentation();
444 if (!EnsureCompiledIrregexp(jsregexp, is_ascii)) { 434 if (!EnsureCompiledIrregexp(jsregexp, is_ascii)) {
445 return Handle<Object>::null(); 435 return Handle<Object>::null();
446 } 436 }
447 Handle<Code> code(RegExpImpl::IrregexpNativeCode(*regexp, is_ascii)); 437 Handle<Code> code(RegExpImpl::IrregexpNativeCode(*regexp, is_ascii));
448 res = RegExpMacroAssemblerIA32::Match(code, 438 res = RegExpMacroAssemblerIA32::Match(code,
449 subject, 439 subject,
450 offsets_vector, 440 offsets_vector,
451 offsets.length(), 441 offsets.length(),
452 previous_index); 442 previous_index);
453 // If result is RETRY, the string have changed representation, and we 443 // If result is RETRY, the string have changed representation, and we
454 // must restart from scratch. 444 // must restart from scratch.
455 } while (res == RegExpMacroAssemblerIA32::RETRY); 445 } while (res == RegExpMacroAssemblerIA32::RETRY);
456 if (res == RegExpMacroAssemblerIA32::EXCEPTION) { 446 if (res == RegExpMacroAssemblerIA32::EXCEPTION) {
457 ASSERT(Top::has_pending_exception()); 447 ASSERT(Top::has_pending_exception());
458 return Handle<Object>::null(); 448 return Handle<Object>::null();
459 } 449 }
460 ASSERT(res == RegExpMacroAssemblerIA32::SUCCESS 450 ASSERT(res == RegExpMacroAssemblerIA32::SUCCESS
461 || res == RegExpMacroAssemblerIA32::FAILURE); 451 || res == RegExpMacroAssemblerIA32::FAILURE);
462 452
463 rc = (res == RegExpMacroAssemblerIA32::SUCCESS); 453 rc = (res == RegExpMacroAssemblerIA32::SUCCESS);
454 #else
455 UNREACHABLE();
464 #endif 456 #endif
465 } else { 457 } else {
466 bool is_ascii = subject->IsAsciiRepresentation(); 458 bool is_ascii = subject->IsAsciiRepresentation();
467 if (!EnsureCompiledIrregexp(jsregexp, is_ascii)) { 459 if (!EnsureCompiledIrregexp(jsregexp, is_ascii)) {
468 return Handle<Object>::null(); 460 return Handle<Object>::null();
469 } 461 }
470 for (int i = number_of_capture_registers - 1; i >= 0; i--) { 462 for (int i = number_of_capture_registers - 1; i >= 0; i--) {
471 offsets_vector[i] = -1; 463 offsets_vector[i] = -1;
472 } 464 }
473 Handle<ByteArray> byte_codes(IrregexpByteCode(*regexp, is_ascii)); 465 Handle<ByteArray> byte_codes(IrregexpByteCode(*regexp, is_ascii));
(...skipping 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 if (!trace->is_trivial()) { 2506 if (!trace->is_trivial()) {
2515 trace->Flush(compiler, this); 2507 trace->Flush(compiler, this);
2516 return; 2508 return;
2517 } 2509 }
2518 ChoiceNode::Emit(compiler, trace); 2510 ChoiceNode::Emit(compiler, trace);
2519 } 2511 }
2520 2512
2521 2513
2522 int ChoiceNode::CalculatePreloadCharacters(RegExpCompiler* compiler) { 2514 int ChoiceNode::CalculatePreloadCharacters(RegExpCompiler* compiler) {
2523 int preload_characters = EatsAtLeast(4, 0); 2515 int preload_characters = EatsAtLeast(4, 0);
2524 #ifdef CAN_READ_UNALIGNED 2516 #ifdef V8_HOST_CAN_READ_UNALIGNED
2525 bool ascii = compiler->ascii(); 2517 bool ascii = compiler->ascii();
2526 if (ascii) { 2518 if (ascii) {
2527 if (preload_characters > 4) preload_characters = 4; 2519 if (preload_characters > 4) preload_characters = 4;
2528 // We can't preload 3 characters because there is no machine instruction 2520 // We can't preload 3 characters because there is no machine instruction
2529 // to do that. We can't just load 4 because we could be reading 2521 // to do that. We can't just load 4 because we could be reading
2530 // beyond the end of the string, which could cause a memory fault. 2522 // beyond the end of the string, which could cause a memory fault.
2531 if (preload_characters == 3) preload_characters = 2; 2523 if (preload_characters == 3) preload_characters = 2;
2532 } else { 2524 } else {
2533 if (preload_characters > 2) preload_characters = 2; 2525 if (preload_characters > 2) preload_characters = 2;
2534 } 2526 }
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after
4438 node = loop_node; 4430 node = loop_node;
4439 } 4431 }
4440 } 4432 }
4441 data->node = node; 4433 data->node = node;
4442 Analysis analysis(ignore_case); 4434 Analysis analysis(ignore_case);
4443 analysis.EnsureAnalyzed(node); 4435 analysis.EnsureAnalyzed(node);
4444 4436
4445 NodeInfo info = *node->info(); 4437 NodeInfo info = *node->info();
4446 4438
4447 if (RegExpImpl::UseNativeRegexp()) { 4439 if (RegExpImpl::UseNativeRegexp()) {
4448 #ifdef V8_ARCH_ARM 4440 #ifdef V8_TARGET_ARCH_ARM
4449 UNREACHABLE(); 4441 UNREACHABLE();
4450 #endif 4442 #endif
4451 #ifdef V8_ARCH_X64 4443 #ifdef V8_TARGET_ARCH_X64
4452 UNREACHABLE(); 4444 UNREACHABLE();
4453 #endif 4445 #endif
4454 #ifdef V8_ARCH_IA32 4446 #ifdef V8_TARGET_ARCH_IA32
4455 RegExpMacroAssemblerIA32::Mode mode; 4447 RegExpMacroAssemblerIA32::Mode mode;
4456 if (is_ascii) { 4448 if (is_ascii) {
4457 mode = RegExpMacroAssemblerIA32::ASCII; 4449 mode = RegExpMacroAssemblerIA32::ASCII;
4458 } else { 4450 } else {
4459 mode = RegExpMacroAssemblerIA32::UC16; 4451 mode = RegExpMacroAssemblerIA32::UC16;
4460 } 4452 }
4461 RegExpMacroAssemblerIA32 macro_assembler(mode, 4453 RegExpMacroAssemblerIA32 macro_assembler(mode,
4462 (data->capture_count + 1) * 2); 4454 (data->capture_count + 1) * 2);
4463 return compiler.Assemble(&macro_assembler, 4455 return compiler.Assemble(&macro_assembler,
4464 node, 4456 node,
4465 data->capture_count, 4457 data->capture_count,
4466 pattern); 4458 pattern);
4467 #endif 4459 #endif
4468 } 4460 }
4469 EmbeddedVector<byte, 1024> codes; 4461 EmbeddedVector<byte, 1024> codes;
4470 RegExpMacroAssemblerIrregexp macro_assembler(codes); 4462 RegExpMacroAssemblerIrregexp macro_assembler(codes);
4471 return compiler.Assemble(&macro_assembler, 4463 return compiler.Assemble(&macro_assembler,
4472 node, 4464 node,
4473 data->capture_count, 4465 data->capture_count,
4474 pattern); 4466 pattern);
4475 } 4467 }
4476 4468
4477 4469
4478 }} // namespace v8::internal 4470 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « src/jsregexp.h ('k') | src/macro-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698