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

Side by Side Diff: src/regexp-macro-assembler.cc

Issue 2807031: [Isolates] RegExpStack and memory allocation limits (statics #6) (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: -> is different than . Created 10 years, 5 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/platform-win32.cc ('k') | src/regexp-stack.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 2008 the V8 project authors. All rights reserved. 1 // Copyright 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 150
151 151
152 NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Execute( 152 NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Execute(
153 Code* code, 153 Code* code,
154 String* input, 154 String* input,
155 int start_offset, 155 int start_offset,
156 const byte* input_start, 156 const byte* input_start,
157 const byte* input_end, 157 const byte* input_end,
158 int* output) { 158 int* output) {
159 Isolate* isolate = Isolate::Current();
159 typedef int (*matcher)(String*, int, const byte*, 160 typedef int (*matcher)(String*, int, const byte*,
160 const byte*, int*, Address, int); 161 const byte*, int*, Address, int);
161 matcher matcher_func = FUNCTION_CAST<matcher>(code->entry()); 162 matcher matcher_func = FUNCTION_CAST<matcher>(code->entry());
162 163
163 // Ensure that the minimum stack has been allocated. 164 // Ensure that the minimum stack has been allocated.
164 RegExpStack stack; 165 RegExpStackScope stack_scope(isolate);
165 Address stack_base = RegExpStack::stack_base(); 166 Address stack_base = stack_scope.stack()->stack_base();
166 167
167 int direct_call = 0; 168 int direct_call = 0;
168 int result = CALL_GENERATED_REGEXP_CODE(matcher_func, 169 int result = CALL_GENERATED_REGEXP_CODE(matcher_func,
169 input, 170 input,
170 start_offset, 171 start_offset,
171 input_start, 172 input_start,
172 input_end, 173 input_end,
173 output, 174 output,
174 stack_base, 175 stack_base,
175 direct_call); 176 direct_call);
176 ASSERT(result <= SUCCESS); 177 ASSERT(result <= SUCCESS);
177 ASSERT(result >= RETRY); 178 ASSERT(result >= RETRY);
178 179
179 if (result == EXCEPTION && !Isolate::Current()->has_pending_exception()) { 180 if (result == EXCEPTION && !isolate->has_pending_exception()) {
180 // We detected a stack overflow (on the backtrack stack) in RegExp code, 181 // We detected a stack overflow (on the backtrack stack) in RegExp code,
181 // but haven't created the exception yet. 182 // but haven't created the exception yet.
182 Isolate::Current()->StackOverflow(); 183 isolate->StackOverflow();
183 } 184 }
184 return static_cast<Result>(result); 185 return static_cast<Result>(result);
185 } 186 }
186 187
187 188
188 const byte NativeRegExpMacroAssembler::word_character_map[] = { 189 const byte NativeRegExpMacroAssembler::word_character_map[] = {
189 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 190 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u,
190 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 191 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u,
191 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 192 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u,
192 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 193 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u, 0x00u,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 237 }
237 } 238 }
238 } 239 }
239 } 240 }
240 return 1; 241 return 1;
241 } 242 }
242 243
243 244
244 Address NativeRegExpMacroAssembler::GrowStack(Address stack_pointer, 245 Address NativeRegExpMacroAssembler::GrowStack(Address stack_pointer,
245 Address* stack_base) { 246 Address* stack_base) {
246 size_t size = RegExpStack::stack_capacity(); 247 RegExpStack* regexp_stack = Isolate::Current()->regexp_stack();
247 Address old_stack_base = RegExpStack::stack_base(); 248 size_t size = regexp_stack->stack_capacity();
249 Address old_stack_base = regexp_stack->stack_base();
248 ASSERT(old_stack_base == *stack_base); 250 ASSERT(old_stack_base == *stack_base);
249 ASSERT(stack_pointer <= old_stack_base); 251 ASSERT(stack_pointer <= old_stack_base);
250 ASSERT(static_cast<size_t>(old_stack_base - stack_pointer) <= size); 252 ASSERT(static_cast<size_t>(old_stack_base - stack_pointer) <= size);
251 Address new_stack_base = RegExpStack::EnsureCapacity(size * 2); 253 Address new_stack_base = regexp_stack->EnsureCapacity(size * 2);
252 if (new_stack_base == NULL) { 254 if (new_stack_base == NULL) {
253 return NULL; 255 return NULL;
254 } 256 }
255 *stack_base = new_stack_base; 257 *stack_base = new_stack_base;
256 intptr_t stack_content_size = old_stack_base - stack_pointer; 258 intptr_t stack_content_size = old_stack_base - stack_pointer;
257 return new_stack_base - stack_content_size; 259 return new_stack_base - stack_content_size;
258 } 260 }
259 261
260 #endif // V8_INTERPRETED_REGEXP 262 #endif // V8_INTERPRETED_REGEXP
261 263
262 } } // namespace v8::internal 264 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-win32.cc ('k') | src/regexp-stack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698