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

Side by Side Diff: src/jsregexp.cc

Issue 516913003: Do not expose termination exceptions to the Exception API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address comment Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/json-stringifier.h ('k') | src/objects.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/ast.h" 7 #include "src/ast.h"
8 #include "src/base/platform/platform.h" 8 #include "src/base/platform/platform.h"
9 #include "src/compilation-cache.h" 9 #include "src/compilation-cache.h"
10 #include "src/compiler.h" 10 #include "src/compiler.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 Handle<JSRegExp> re, 81 Handle<JSRegExp> re,
82 Handle<String> pattern, 82 Handle<String> pattern,
83 Handle<String> error_text, 83 Handle<String> error_text,
84 const char* message) { 84 const char* message) {
85 Isolate* isolate = re->GetIsolate(); 85 Isolate* isolate = re->GetIsolate();
86 Factory* factory = isolate->factory(); 86 Factory* factory = isolate->factory();
87 Handle<FixedArray> elements = factory->NewFixedArray(2); 87 Handle<FixedArray> elements = factory->NewFixedArray(2);
88 elements->set(0, *pattern); 88 elements->set(0, *pattern);
89 elements->set(1, *error_text); 89 elements->set(1, *error_text);
90 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); 90 Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
91 Handle<Object> regexp_err = factory->NewSyntaxError(message, array); 91 Handle<Object> regexp_err;
92 return isolate->Throw<Object>(regexp_err); 92 THROW_NEW_ERROR(isolate, NewSyntaxError(message, array), Object);
93 } 93 }
94 94
95 95
96 ContainedInLattice AddRange(ContainedInLattice containment, 96 ContainedInLattice AddRange(ContainedInLattice containment,
97 const int* ranges, 97 const int* ranges,
98 int ranges_length, 98 int ranges_length,
99 Interval new_range) { 99 Interval new_range) {
100 DCHECK((ranges_length & 1) == 1); 100 DCHECK((ranges_length & 1) == 1);
101 DCHECK(ranges[ranges_length - 1] == String::kMaxUtf16CodeUnit + 1); 101 DCHECK(ranges[ranges_length - 1] == String::kMaxUtf16CodeUnit + 1);
102 if (containment == kLatticeUnknown) return containment; 102 if (containment == kLatticeUnknown) return containment;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 if (saved_code->IsCode()) { 365 if (saved_code->IsCode()) {
366 // Reinstate the code in the original place. 366 // Reinstate the code in the original place.
367 re->SetDataAt(JSRegExp::code_index(is_ascii), saved_code); 367 re->SetDataAt(JSRegExp::code_index(is_ascii), saved_code);
368 DCHECK(compiled_code->IsSmi()); 368 DCHECK(compiled_code->IsSmi());
369 return true; 369 return true;
370 } 370 }
371 return CompileIrregexp(re, sample_subject, is_ascii); 371 return CompileIrregexp(re, sample_subject, is_ascii);
372 } 372 }
373 373
374 374
375 static bool CreateRegExpErrorObjectAndThrow(Handle<JSRegExp> re, 375 static void CreateRegExpErrorObjectAndThrow(Handle<JSRegExp> re, bool is_ascii,
376 bool is_ascii,
377 Handle<String> error_message, 376 Handle<String> error_message,
378 Isolate* isolate) { 377 Isolate* isolate) {
379 Factory* factory = isolate->factory(); 378 Factory* factory = isolate->factory();
380 Handle<FixedArray> elements = factory->NewFixedArray(2); 379 Handle<FixedArray> elements = factory->NewFixedArray(2);
381 elements->set(0, re->Pattern()); 380 elements->set(0, re->Pattern());
382 elements->set(1, *error_message); 381 elements->set(1, *error_message);
383 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); 382 Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
384 Handle<Object> regexp_err = 383 Handle<Object> error;
384 MaybeHandle<Object> maybe_error =
385 factory->NewSyntaxError("malformed_regexp", array); 385 factory->NewSyntaxError("malformed_regexp", array);
386 isolate->Throw(*regexp_err); 386 if (maybe_error.ToHandle(&error)) isolate->Throw(*error);
387 return false;
388 } 387 }
389 388
390 389
391 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re, 390 bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re,
392 Handle<String> sample_subject, 391 Handle<String> sample_subject,
393 bool is_ascii) { 392 bool is_ascii) {
394 // Compile the RegExp. 393 // Compile the RegExp.
395 Isolate* isolate = re->GetIsolate(); 394 Isolate* isolate = re->GetIsolate();
396 Zone zone(isolate); 395 Zone zone(isolate);
397 PostponeInterruptsScope postpone(isolate); 396 PostponeInterruptsScope postpone(isolate);
(...skipping 5706 matching lines...) Expand 10 before | Expand all | Expand 10 after
6104 } 6103 }
6105 6104
6106 return compiler.Assemble(&macro_assembler, 6105 return compiler.Assemble(&macro_assembler,
6107 node, 6106 node,
6108 data->capture_count, 6107 data->capture_count,
6109 pattern); 6108 pattern);
6110 } 6109 }
6111 6110
6112 6111
6113 }} // namespace v8::internal 6112 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « src/json-stringifier.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698