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

Side by Side Diff: src/jsregexp.cc

Issue 10795: Fixes to RegExp-IA32. (Closed)
Patch Set: Created 12 years 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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 24 matching lines...) Expand all
35 #include "factory.h" 35 #include "factory.h"
36 #include "jsregexp-inl.h" 36 #include "jsregexp-inl.h"
37 #include "platform.h" 37 #include "platform.h"
38 #include "runtime.h" 38 #include "runtime.h"
39 #include "top.h" 39 #include "top.h"
40 #include "compilation-cache.h" 40 #include "compilation-cache.h"
41 #include "string-stream.h" 41 #include "string-stream.h"
42 #include "parser.h" 42 #include "parser.h"
43 #include "assembler-irregexp.h" 43 #include "assembler-irregexp.h"
44 #include "regexp-macro-assembler.h" 44 #include "regexp-macro-assembler.h"
45 #include "regexp-macro-assembler-tracer.h"
45 #include "regexp-macro-assembler-irregexp.h" 46 #include "regexp-macro-assembler-irregexp.h"
46 47
47 #ifdef ARM 48 #ifdef ARM
48 #include "regexp-macro-assembler-arm.h" 49 #include "regexp-macro-assembler-arm.h"
49 #else // IA32 50 #else // IA32
50 #include "macro-assembler-ia32.h" 51 #include "macro-assembler-ia32.h"
51 #include "regexp-macro-assembler-ia32.h" 52 #include "regexp-macro-assembler-ia32.h"
52 #endif 53 #endif
53 54
54 #include "interpreter-irregexp.h" 55 #include "interpreter-irregexp.h"
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 ignore_case_(ignore_case) { 938 ignore_case_(ignore_case) {
938 accept_ = new EndNode(EndNode::ACCEPT); 939 accept_ = new EndNode(EndNode::ACCEPT);
939 backtrack_ = new EndNode(EndNode::BACKTRACK); 940 backtrack_ = new EndNode(EndNode::BACKTRACK);
940 } 941 }
941 942
942 943
943 Handle<FixedArray> RegExpCompiler::Assemble( 944 Handle<FixedArray> RegExpCompiler::Assemble(
944 RegExpMacroAssembler* macro_assembler, 945 RegExpMacroAssembler* macro_assembler,
945 RegExpNode* start, 946 RegExpNode* start,
946 int capture_count) { 947 int capture_count) {
947 macro_assembler_ = macro_assembler; 948 #ifdef DEBUG
949 if (FLAG_trace_regexp_assembler) {
950 macro_assembler_ = new RegExpMacroAssemblerTracer(macro_assembler);
951 } else
952 #endif
953 macro_assembler_ = macro_assembler;
948 List <RegExpNode*> work_list(0); 954 List <RegExpNode*> work_list(0);
949 work_list_ = &work_list; 955 work_list_ = &work_list;
950 Label fail; 956 Label fail;
951 macro_assembler->PushBacktrack(&fail); 957 macro_assembler_->PushBacktrack(&fail);
952 if (!start->GoTo(this)) { 958 if (!start->GoTo(this)) {
953 fail.Unuse(); 959 fail.Unuse();
954 return Handle<FixedArray>::null(); 960 return Handle<FixedArray>::null();
955 } 961 }
956 while (!work_list.is_empty()) { 962 while (!work_list.is_empty()) {
957 if (!work_list.RemoveLast()->GoTo(this)) { 963 if (!work_list.RemoveLast()->GoTo(this)) {
958 fail.Unuse(); 964 fail.Unuse();
959 return Handle<FixedArray>::null(); 965 return Handle<FixedArray>::null();
960 } 966 }
961 } 967 }
962 macro_assembler->Bind(&fail); 968 macro_assembler_->Bind(&fail);
963 macro_assembler->Fail(); 969 macro_assembler_->Fail();
964 Handle<FixedArray> array = 970 Handle<FixedArray> array =
965 Factory::NewFixedArray(RegExpImpl::kIrregexpDataLength); 971 Factory::NewFixedArray(RegExpImpl::kIrregexpDataLength);
966 array->set(RegExpImpl::kIrregexpImplementationIndex, 972 array->set(RegExpImpl::kIrregexpImplementationIndex,
967 Smi::FromInt(macro_assembler->Implementation())); 973 Smi::FromInt(macro_assembler_->Implementation()));
968 array->set(RegExpImpl::kIrregexpNumberOfRegistersIndex, 974 array->set(RegExpImpl::kIrregexpNumberOfRegistersIndex,
969 Smi::FromInt(next_register_)); 975 Smi::FromInt(next_register_));
970 array->set(RegExpImpl::kIrregexpNumberOfCapturesIndex, 976 array->set(RegExpImpl::kIrregexpNumberOfCapturesIndex,
971 Smi::FromInt(capture_count)); 977 Smi::FromInt(capture_count));
972 Handle<Object> code = macro_assembler->GetCode(); 978 Handle<Object> code = macro_assembler_->GetCode();
973 array->set(RegExpImpl::kIrregexpCodeIndex, *code); 979 array->set(RegExpImpl::kIrregexpCodeIndex, *code);
974 work_list_ = NULL; 980 work_list_ = NULL;
981 #ifdef DEBUG
982 if (FLAG_trace_regexp_assembler) {
983 delete macro_assembler_;
984 }
985 #endif
975 return array; 986 return array;
976 } 987 }
977 988
978 989
979 bool RegExpNode::GoTo(RegExpCompiler* compiler) { 990 bool RegExpNode::GoTo(RegExpCompiler* compiler) {
980 // TODO(erikcorry): Implement support. 991 // TODO(erikcorry): Implement support.
981 if (info_.follows_word_interest || 992 if (info_.follows_word_interest ||
982 info_.follows_newline_interest || 993 info_.follows_newline_interest ||
983 info_.follows_start_interest) { 994 info_.follows_start_interest) {
984 return false; 995 return false;
(...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after
2649 byte codes[1024]; 2660 byte codes[1024];
2650 IrregexpAssembler assembler(Vector<byte>(codes, 1024)); 2661 IrregexpAssembler assembler(Vector<byte>(codes, 1024));
2651 RegExpMacroAssemblerIrregexp macro_assembler(&assembler); 2662 RegExpMacroAssemblerIrregexp macro_assembler(&assembler);
2652 return compiler.Assemble(&macro_assembler, 2663 return compiler.Assemble(&macro_assembler,
2653 node, 2664 node,
2654 input->capture_count); 2665 input->capture_count);
2655 } 2666 }
2656 2667
2657 2668
2658 }} // namespace v8::internal 2669 }} // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698