OLD | NEW |
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 4157 matching lines...) Loading... |
4168 // Shorten string and fill | 4168 // Shorten string and fill |
4169 int string_size = ResultSeqString::SizeFor(position); | 4169 int string_size = ResultSeqString::SizeFor(position); |
4170 int allocated_string_size = ResultSeqString::SizeFor(new_length); | 4170 int allocated_string_size = ResultSeqString::SizeFor(new_length); |
4171 int delta = allocated_string_size - string_size; | 4171 int delta = allocated_string_size - string_size; |
4172 | 4172 |
4173 answer->set_length(position); | 4173 answer->set_length(position); |
4174 if (delta == 0) return *answer; | 4174 if (delta == 0) return *answer; |
4175 | 4175 |
4176 Address end_of_string = answer->address() + string_size; | 4176 Address end_of_string = answer->address() + string_size; |
4177 Heap* heap = isolate->heap(); | 4177 Heap* heap = isolate->heap(); |
| 4178 |
| 4179 // The trimming is performed on a newly allocated object, which is on a |
| 4180 // fresly allocated page or on an already swept page. Hence, the sweeper |
| 4181 // thread can not get confused with the filler creation. No synchronization |
| 4182 // needed. |
4178 heap->CreateFillerObjectAt(end_of_string, delta); | 4183 heap->CreateFillerObjectAt(end_of_string, delta); |
4179 heap->AdjustLiveBytes(answer->address(), -delta, Heap::FROM_MUTATOR); | 4184 heap->AdjustLiveBytes(answer->address(), -delta, Heap::FROM_MUTATOR); |
4180 return *answer; | 4185 return *answer; |
4181 } | 4186 } |
4182 | 4187 |
4183 | 4188 |
4184 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceGlobalRegExpWithString) { | 4189 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceGlobalRegExpWithString) { |
4185 HandleScope scope(isolate); | 4190 HandleScope scope(isolate); |
4186 ASSERT(args.length() == 4); | 4191 ASSERT(args.length() == 4); |
4187 | 4192 |
(...skipping 10934 matching lines...) Loading... |
15122 // Handle last resort GC and make sure to allow future allocations | 15127 // Handle last resort GC and make sure to allow future allocations |
15123 // to grow the heap without causing GCs (if possible). | 15128 // to grow the heap without causing GCs (if possible). |
15124 isolate->counters()->gc_last_resort_from_js()->Increment(); | 15129 isolate->counters()->gc_last_resort_from_js()->Increment(); |
15125 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 15130 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
15126 "Runtime::PerformGC"); | 15131 "Runtime::PerformGC"); |
15127 } | 15132 } |
15128 } | 15133 } |
15129 | 15134 |
15130 | 15135 |
15131 } } // namespace v8::internal | 15136 } } // namespace v8::internal |
OLD | NEW |