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

Side by Side Diff: src/jsregexp.cc

Issue 153773002: A64: Synchronize with r16679. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/jsregexp.h ('k') | src/liveedit.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 public: 1080 public:
1081 explicit RecursionCheck(RegExpCompiler* compiler) : compiler_(compiler) { 1081 explicit RecursionCheck(RegExpCompiler* compiler) : compiler_(compiler) {
1082 compiler->IncrementRecursionDepth(); 1082 compiler->IncrementRecursionDepth();
1083 } 1083 }
1084 ~RecursionCheck() { compiler_->DecrementRecursionDepth(); } 1084 ~RecursionCheck() { compiler_->DecrementRecursionDepth(); }
1085 private: 1085 private:
1086 RegExpCompiler* compiler_; 1086 RegExpCompiler* compiler_;
1087 }; 1087 };
1088 1088
1089 1089
1090 static RegExpEngine::CompilationResult IrregexpRegExpTooBig() { 1090 static RegExpEngine::CompilationResult IrregexpRegExpTooBig(Isolate* isolate) {
1091 return RegExpEngine::CompilationResult("RegExp too big"); 1091 return RegExpEngine::CompilationResult(isolate, "RegExp too big");
1092 } 1092 }
1093 1093
1094 1094
1095 // Attempts to compile the regexp using an Irregexp code generator. Returns 1095 // Attempts to compile the regexp using an Irregexp code generator. Returns
1096 // a fixed array or a null handle depending on whether it succeeded. 1096 // a fixed array or a null handle depending on whether it succeeded.
1097 RegExpCompiler::RegExpCompiler(int capture_count, bool ignore_case, bool ascii, 1097 RegExpCompiler::RegExpCompiler(int capture_count, bool ignore_case, bool ascii,
1098 Zone* zone) 1098 Zone* zone)
1099 : next_register_(2 * (capture_count + 1)), 1099 : next_register_(2 * (capture_count + 1)),
1100 work_list_(NULL), 1100 work_list_(NULL),
1101 recursion_depth_(0), 1101 recursion_depth_(0),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 work_list_ = &work_list; 1138 work_list_ = &work_list;
1139 Label fail; 1139 Label fail;
1140 macro_assembler_->PushBacktrack(&fail); 1140 macro_assembler_->PushBacktrack(&fail);
1141 Trace new_trace; 1141 Trace new_trace;
1142 start->Emit(this, &new_trace); 1142 start->Emit(this, &new_trace);
1143 macro_assembler_->Bind(&fail); 1143 macro_assembler_->Bind(&fail);
1144 macro_assembler_->Fail(); 1144 macro_assembler_->Fail();
1145 while (!work_list.is_empty()) { 1145 while (!work_list.is_empty()) {
1146 work_list.RemoveLast()->Emit(this, &new_trace); 1146 work_list.RemoveLast()->Emit(this, &new_trace);
1147 } 1147 }
1148 if (reg_exp_too_big_) return IrregexpRegExpTooBig(); 1148 if (reg_exp_too_big_) return IrregexpRegExpTooBig(zone_->isolate());
1149 1149
1150 Handle<HeapObject> code = macro_assembler_->GetCode(pattern); 1150 Handle<HeapObject> code = macro_assembler_->GetCode(pattern);
1151 heap->IncreaseTotalRegexpCodeGenerated(code->Size()); 1151 heap->IncreaseTotalRegexpCodeGenerated(code->Size());
1152 work_list_ = NULL; 1152 work_list_ = NULL;
1153 #ifdef DEBUG 1153 #ifdef DEBUG
1154 if (FLAG_print_code) { 1154 if (FLAG_print_code) {
1155 Handle<Code>::cast(code)->Disassemble(*pattern->ToCString()); 1155 Handle<Code>::cast(code)->Disassemble(*pattern->ToCString());
1156 } 1156 }
1157 if (FLAG_trace_regexp_assembler) { 1157 if (FLAG_trace_regexp_assembler) {
1158 delete macro_assembler_; 1158 delete macro_assembler_;
(...skipping 4670 matching lines...) Expand 10 before | Expand all | Expand 10 after
5829 RegExpAtom* atom = text.atom(); 5829 RegExpAtom* atom = text.atom();
5830 for (int j = 0; j < atom->length(); j++, offset++) { 5830 for (int j = 0; j < atom->length(); j++, offset++) {
5831 if (offset >= bm->length()) { 5831 if (offset >= bm->length()) {
5832 if (initial_offset == 0) set_bm_info(not_at_start, bm); 5832 if (initial_offset == 0) set_bm_info(not_at_start, bm);
5833 return; 5833 return;
5834 } 5834 }
5835 uc16 character = atom->data()[j]; 5835 uc16 character = atom->data()[j];
5836 if (bm->compiler()->ignore_case()) { 5836 if (bm->compiler()->ignore_case()) {
5837 unibrow::uchar chars[unibrow::Ecma262UnCanonicalize::kMaxWidth]; 5837 unibrow::uchar chars[unibrow::Ecma262UnCanonicalize::kMaxWidth];
5838 int length = GetCaseIndependentLetters( 5838 int length = GetCaseIndependentLetters(
5839 ISOLATE, 5839 Isolate::Current(),
5840 character, 5840 character,
5841 bm->max_char() == String::kMaxOneByteCharCode, 5841 bm->max_char() == String::kMaxOneByteCharCode,
5842 chars); 5842 chars);
5843 for (int j = 0; j < length; j++) { 5843 for (int j = 0; j < length; j++) {
5844 bm->Set(offset, chars[j]); 5844 bm->Set(offset, chars[j]);
5845 } 5845 }
5846 } else { 5846 } else {
5847 if (character <= max_char) bm->Set(offset, character); 5847 if (character <= max_char) bm->Set(offset, character);
5848 } 5848 }
5849 } 5849 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
5994 RegExpEngine::CompilationResult RegExpEngine::Compile( 5994 RegExpEngine::CompilationResult RegExpEngine::Compile(
5995 RegExpCompileData* data, 5995 RegExpCompileData* data,
5996 bool ignore_case, 5996 bool ignore_case,
5997 bool is_global, 5997 bool is_global,
5998 bool is_multiline, 5998 bool is_multiline,
5999 Handle<String> pattern, 5999 Handle<String> pattern,
6000 Handle<String> sample_subject, 6000 Handle<String> sample_subject,
6001 bool is_ascii, 6001 bool is_ascii,
6002 Zone* zone) { 6002 Zone* zone) {
6003 if ((data->capture_count + 1) * 2 - 1 > RegExpMacroAssembler::kMaxRegister) { 6003 if ((data->capture_count + 1) * 2 - 1 > RegExpMacroAssembler::kMaxRegister) {
6004 return IrregexpRegExpTooBig(); 6004 return IrregexpRegExpTooBig(zone->isolate());
6005 } 6005 }
6006 RegExpCompiler compiler(data->capture_count, ignore_case, is_ascii, zone); 6006 RegExpCompiler compiler(data->capture_count, ignore_case, is_ascii, zone);
6007 6007
6008 // Sample some characters from the middle of the string. 6008 // Sample some characters from the middle of the string.
6009 static const int kSampleSize = 128; 6009 static const int kSampleSize = 128;
6010 6010
6011 FlattenString(sample_subject); 6011 FlattenString(sample_subject);
6012 int chars_sampled = 0; 6012 int chars_sampled = 0;
6013 int half_way = (sample_subject->length() - kSampleSize) / 2; 6013 int half_way = (sample_subject->length() - kSampleSize) / 2;
6014 for (int i = Max(0, half_way); 6014 for (int i = Max(0, half_way);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
6058 node = node->FilterASCII(RegExpCompiler::kMaxRecursion, ignore_case); 6058 node = node->FilterASCII(RegExpCompiler::kMaxRecursion, ignore_case);
6059 } 6059 }
6060 } 6060 }
6061 6061
6062 if (node == NULL) node = new(zone) EndNode(EndNode::BACKTRACK, zone); 6062 if (node == NULL) node = new(zone) EndNode(EndNode::BACKTRACK, zone);
6063 data->node = node; 6063 data->node = node;
6064 Analysis analysis(ignore_case, is_ascii); 6064 Analysis analysis(ignore_case, is_ascii);
6065 analysis.EnsureAnalyzed(node); 6065 analysis.EnsureAnalyzed(node);
6066 if (analysis.has_failed()) { 6066 if (analysis.has_failed()) {
6067 const char* error_message = analysis.error_message(); 6067 const char* error_message = analysis.error_message();
6068 return CompilationResult(error_message); 6068 return CompilationResult(zone->isolate(), error_message);
6069 } 6069 }
6070 6070
6071 // Create the correct assembler for the architecture. 6071 // Create the correct assembler for the architecture.
6072 #ifndef V8_INTERPRETED_REGEXP 6072 #ifndef V8_INTERPRETED_REGEXP
6073 // Native regexp implementation. 6073 // Native regexp implementation.
6074 6074
6075 NativeRegExpMacroAssembler::Mode mode = 6075 NativeRegExpMacroAssembler::Mode mode =
6076 is_ascii ? NativeRegExpMacroAssembler::ASCII 6076 is_ascii ? NativeRegExpMacroAssembler::ASCII
6077 : NativeRegExpMacroAssembler::UC16; 6077 : NativeRegExpMacroAssembler::UC16;
6078 6078
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
6118 } 6118 }
6119 6119
6120 return compiler.Assemble(&macro_assembler, 6120 return compiler.Assemble(&macro_assembler,
6121 node, 6121 node,
6122 data->capture_count, 6122 data->capture_count,
6123 pattern); 6123 pattern);
6124 } 6124 }
6125 6125
6126 6126
6127 }} // namespace v8::internal 6127 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « src/jsregexp.h ('k') | src/liveedit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698