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

Side by Side Diff: src/runtime.cc

Issue 7374002: Refactor allocation policies. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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/profile-generator.cc ('k') | src/safepoint-table.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 2314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2325 Heap* heap_; 2325 Heap* heap_;
2326 FixedArrayBuilder array_builder_; 2326 FixedArrayBuilder array_builder_;
2327 Handle<String> subject_; 2327 Handle<String> subject_;
2328 int character_count_; 2328 int character_count_;
2329 bool is_ascii_; 2329 bool is_ascii_;
2330 }; 2330 };
2331 2331
2332 2332
2333 class CompiledReplacement { 2333 class CompiledReplacement {
2334 public: 2334 public:
2335 CompiledReplacement() 2335 explicit CompiledReplacement(Zone* zone)
2336 : parts_(1), replacement_substrings_(0) {} 2336 : parts_(zone, 1), replacement_substrings_(zone, 0) {}
2337 2337
2338 void Compile(Handle<String> replacement, 2338 void Compile(Handle<String> replacement,
2339 int capture_count, 2339 int capture_count,
2340 int subject_length); 2340 int subject_length);
2341 2341
2342 void Apply(ReplacementStringBuilder* builder, 2342 void Apply(ReplacementStringBuilder* builder,
2343 int match_from, 2343 int match_from,
2344 int match_to, 2344 int match_to,
2345 Handle<JSArray> last_match_info); 2345 Handle<JSArray> last_match_info);
2346 2346
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2618 if (match.is_null()) { 2618 if (match.is_null()) {
2619 return Failure::Exception(); 2619 return Failure::Exception();
2620 } 2620 }
2621 if (match->IsNull()) { 2621 if (match->IsNull()) {
2622 return *subject_handle; 2622 return *subject_handle;
2623 } 2623 }
2624 2624
2625 int capture_count = regexp_handle->CaptureCount(); 2625 int capture_count = regexp_handle->CaptureCount();
2626 2626
2627 // CompiledReplacement uses zone allocation. 2627 // CompiledReplacement uses zone allocation.
2628 ZoneScope zone(isolate, DELETE_ON_EXIT); 2628 ZoneScope zone_scope(isolate, DELETE_ON_EXIT);
2629 CompiledReplacement compiled_replacement; 2629 CompiledReplacement compiled_replacement(isolate->zone());
2630 compiled_replacement.Compile(replacement_handle, 2630 compiled_replacement.Compile(replacement_handle,
2631 capture_count, 2631 capture_count,
2632 length); 2632 length);
2633 2633
2634 bool is_global = regexp_handle->GetFlags().is_global(); 2634 bool is_global = regexp_handle->GetFlags().is_global();
2635 2635
2636 // Guessing the number of parts that the final result string is built 2636 // Guessing the number of parts that the final result string is built
2637 // from. Global regexps can match any number of times, so we guess 2637 // from. Global regexps can match any number of times, so we guess
2638 // conservatively. 2638 // conservatively.
2639 int expected_parts = 2639 int expected_parts =
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
3133 3133
3134 if (match.is_null()) { 3134 if (match.is_null()) {
3135 return Failure::Exception(); 3135 return Failure::Exception();
3136 } 3136 }
3137 if (match->IsNull()) { 3137 if (match->IsNull()) {
3138 return isolate->heap()->null_value(); 3138 return isolate->heap()->null_value();
3139 } 3139 }
3140 int length = subject->length(); 3140 int length = subject->length();
3141 3141
3142 ZoneScope zone_space(isolate, DELETE_ON_EXIT); 3142 ZoneScope zone_space(isolate, DELETE_ON_EXIT);
3143 ZoneList<int> offsets(8); 3143 ZoneList<int> offsets(isolate->zone(), 8);
3144 int start; 3144 int start;
3145 int end; 3145 int end;
3146 do { 3146 do {
3147 { 3147 {
3148 AssertNoAllocation no_alloc; 3148 AssertNoAllocation no_alloc;
3149 FixedArray* elements = FixedArray::cast(regexp_info->elements()); 3149 FixedArray* elements = FixedArray::cast(regexp_info->elements());
3150 start = Smi::cast(elements->get(RegExpImpl::kFirstCapture))->value(); 3150 start = Smi::cast(elements->get(RegExpImpl::kFirstCapture))->value();
3151 end = Smi::cast(elements->get(RegExpImpl::kFirstCapture + 1))->value(); 3151 end = Smi::cast(elements->get(RegExpImpl::kFirstCapture + 1))->value();
3152 } 3152 }
3153 offsets.Add(start); 3153 offsets.Add(start);
(...skipping 2649 matching lines...) Expand 10 before | Expand all | Expand 10 after
5803 // of the subject. 5803 // of the subject.
5804 5804
5805 if (!subject->IsFlat()) FlattenString(subject); 5805 if (!subject->IsFlat()) FlattenString(subject);
5806 5806
5807 static const int kMaxInitialListCapacity = 16; 5807 static const int kMaxInitialListCapacity = 16;
5808 5808
5809 ZoneScope scope(isolate, DELETE_ON_EXIT); 5809 ZoneScope scope(isolate, DELETE_ON_EXIT);
5810 5810
5811 // Find (up to limit) indices of separator and end-of-string in subject 5811 // Find (up to limit) indices of separator and end-of-string in subject
5812 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit); 5812 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit);
5813 ZoneList<int> indices(initial_capacity); 5813 ZoneList<int> indices(isolate->zone(), initial_capacity);
5814 if (!pattern->IsFlat()) FlattenString(pattern); 5814 if (!pattern->IsFlat()) FlattenString(pattern);
5815 5815
5816 // No allocation block. 5816 // No allocation block.
5817 { 5817 {
5818 AssertNoAllocation nogc; 5818 AssertNoAllocation nogc;
5819 if (subject->IsAsciiRepresentation()) { 5819 if (subject->IsAsciiRepresentation()) {
5820 Vector<const char> subject_vector = subject->ToAsciiVector(); 5820 Vector<const char> subject_vector = subject->ToAsciiVector();
5821 if (pattern->IsAsciiRepresentation()) { 5821 if (pattern->IsAsciiRepresentation()) {
5822 Vector<const char> pattern_vector = pattern->ToAsciiVector(); 5822 Vector<const char> pattern_vector = pattern->ToAsciiVector();
5823 if (pattern_vector.length() == 1) { 5823 if (pattern_vector.length() == 1) {
(...skipping 6845 matching lines...) Expand 10 before | Expand all | Expand 10 after
12669 } else { 12669 } else {
12670 // Handle last resort GC and make sure to allow future allocations 12670 // Handle last resort GC and make sure to allow future allocations
12671 // to grow the heap without causing GCs (if possible). 12671 // to grow the heap without causing GCs (if possible).
12672 isolate->counters()->gc_last_resort_from_js()->Increment(); 12672 isolate->counters()->gc_last_resort_from_js()->Increment();
12673 isolate->heap()->CollectAllGarbage(false); 12673 isolate->heap()->CollectAllGarbage(false);
12674 } 12674 }
12675 } 12675 }
12676 12676
12677 12677
12678 } } // namespace v8::internal 12678 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.cc ('k') | src/safepoint-table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698