test-alloc.cc revision 44f0eee88ff00398ff7f715fab053374d808c90d
1a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Copyright 2007-2008 the V8 project authors. All rights reserved. 2a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Redistribution and use in source and binary forms, with or without 3a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// modification, are permitted provided that the following conditions are 4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// met: 5a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// 6a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// * Redistributions of source code must retain the above copyright 7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// notice, this list of conditions and the following disclaimer. 8a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// * Redistributions in binary form must reproduce the above 9a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// copyright notice, this list of conditions and the following 10a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// disclaimer in the documentation and/or other materials provided 11a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// with the distribution. 12a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// * Neither the name of Google Inc. nor the names of its 13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// contributors may be used to endorse or promote products derived 14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// from this software without specific prior written permission. 15a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// 16a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 28a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "v8.h" 29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "accessors.h" 30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "cctest.h" 32a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 33a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockusing namespace v8::internal; 35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 375913587db4c6bab03d97bfe44b06289fd6d7270dJohn Reckstatic MaybeObject* AllocateAfterFailures() { 38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static int attempts = 0; 39f87a203d89e1bbb6708282e0b64dbd13d59b723dBen Murdoch if (++attempts < 3) return Failure::RetryAfterGC(); 4044f0eee88ff00398ff7f715fab053374d808c90dSteve Block Heap* heap = Isolate::Current()->heap(); 41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // New space. 4344f0eee88ff00398ff7f715fab053374d808c90dSteve Block NewSpace* new_space = heap->new_space(); 44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kNewSpaceFillerSize = ByteArray::SizeFor(0); 45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block while (new_space->Available() > kNewSpaceFillerSize) { 46f87a203d89e1bbb6708282e0b64dbd13d59b723dBen Murdoch int available_before = static_cast<int>(new_space->Available()); 4744f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->AllocateByteArray(0)->IsFailure()); 48a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block if (available_before == new_space->Available()) { 49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // It seems that we are avoiding new space allocations when 50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // allocation is forced, so no need to fill up new space 51a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // in order to make the test harder. 52a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block break; 53a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block } 54a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block } 5544f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->AllocateByteArray(100)->IsFailure()); 5644f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->AllocateFixedArray(100, NOT_TENURED)->IsFailure()); 57a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Make sure we can allocate through optimized allocation functions 59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // for specific kinds. 6044f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->AllocateFixedArray(100)->IsFailure()); 6144f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->AllocateHeapNumber(0.42)->IsFailure()); 6244f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure()); 6344f0eee88ff00398ff7f715fab053374d808c90dSteve Block Object* object = heap->AllocateJSObject( 6444f0eee88ff00398ff7f715fab053374d808c90dSteve Block *Isolate::Current()->object_function())->ToObjectChecked(); 6544f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->CopyJSObject(JSObject::cast(object))->IsFailure()); 66a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 67a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Old data space. 6844f0eee88ff00398ff7f715fab053374d808c90dSteve Block OldSpace* old_data_space = heap->old_data_space(); 69d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block static const int kOldDataSpaceFillerSize = ByteArray::SizeFor(0); 70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block while (old_data_space->Available() > kOldDataSpaceFillerSize) { 7144f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->AllocateByteArray(0, TENURED)->IsFailure()); 72a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block } 7344f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->AllocateRawAsciiString(100, TENURED)->IsFailure()); 74a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 75a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Large object space. 7644f0eee88ff00398ff7f715fab053374d808c90dSteve Block while (!heap->OldGenerationAllocationLimitReached()) { 7744f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure()); 78a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block } 7944f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure()); 80a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 81a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Map space. 8244f0eee88ff00398ff7f715fab053374d808c90dSteve Block MapSpace* map_space = heap->map_space(); 83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static const int kMapSpaceFillerSize = Map::kSize; 84a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block InstanceType instance_type = JS_OBJECT_TYPE; 85a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block int instance_size = JSObject::kHeaderSize; 86a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block while (map_space->Available() > kMapSpaceFillerSize) { 8744f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->AllocateMap(instance_type, instance_size)->IsFailure()); 88a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block } 8944f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->AllocateMap(instance_type, instance_size)->IsFailure()); 90a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 91a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Test that we can allocate in old pointer space and code space. 9244f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->AllocateFixedArray(100, TENURED)->IsFailure()); 9344f0eee88ff00398ff7f715fab053374d808c90dSteve Block CHECK(!heap->CopyCode(Isolate::Current()->builtins()->builtin( 9444f0eee88ff00398ff7f715fab053374d808c90dSteve Block Builtins::kIllegal))->IsFailure()); 95a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 96a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Return success. 97a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return Smi::FromInt(42); 98a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 99a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 100a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 101a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstatic Handle<Object> Test() { 10244f0eee88ff00398ff7f715fab053374d808c90dSteve Block CALL_HEAP_FUNCTION(ISOLATE, AllocateAfterFailures(), Object); 103a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 104a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 105a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 106a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockTEST(StressHandles) { 107a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block v8::Persistent<v8::Context> env = v8::Context::New(); 108a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block v8::HandleScope scope; 109a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block env->Enter(); 110a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Handle<Object> o = Test(); 111a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block CHECK(o->IsSmi() && Smi::cast(*o)->value() == 42); 112a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block env->Exit(); 113a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 114a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 115a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1165913587db4c6bab03d97bfe44b06289fd6d7270dJohn Reckstatic MaybeObject* TestAccessorGet(Object* object, void*) { 117a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return AllocateAfterFailures(); 118a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 119a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 120a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 121a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockconst AccessorDescriptor kDescriptor = { 122a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block TestAccessorGet, 123a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 0, 124a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 0 125a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 126a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 127a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 128a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockTEST(StressJS) { 129a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block v8::Persistent<v8::Context> env = v8::Context::New(); 130a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block v8::HandleScope scope; 131a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block env->Enter(); 132a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Handle<JSFunction> function = 13344f0eee88ff00398ff7f715fab053374d808c90dSteve Block FACTORY->NewFunction(FACTORY->function_symbol(), FACTORY->null_value()); 134a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Force the creation of an initial map and set the code to 135a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // something empty. 13644f0eee88ff00398ff7f715fab053374d808c90dSteve Block FACTORY->NewJSObject(function); 13744f0eee88ff00398ff7f715fab053374d808c90dSteve Block function->ReplaceCode(Isolate::Current()->builtins()->builtin( 13844f0eee88ff00398ff7f715fab053374d808c90dSteve Block Builtins::kEmptyFunction)); 139a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Patch the map to have an accessor for "get". 140a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Handle<Map> map(function->initial_map()); 141a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Handle<DescriptorArray> instance_descriptors(map->instance_descriptors()); 14244f0eee88ff00398ff7f715fab053374d808c90dSteve Block Handle<Proxy> proxy = FACTORY->NewProxy(&kDescriptor); 14344f0eee88ff00398ff7f715fab053374d808c90dSteve Block instance_descriptors = FACTORY->CopyAppendProxyDescriptor( 144a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block instance_descriptors, 14544f0eee88ff00398ff7f715fab053374d808c90dSteve Block FACTORY->NewStringFromAscii(Vector<const char>("get", 3)), 146a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block proxy, 147a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static_cast<PropertyAttributes>(0)); 148a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block map->set_instance_descriptors(*instance_descriptors); 149a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Add the Foo constructor the global object. 150a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block env->Global()->Set(v8::String::New("Foo"), v8::Utils::ToLocal(function)); 151a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Call the accessor through JavaScript. 152a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block v8::Handle<v8::Value> result = 153a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block v8::Script::Compile(v8::String::New("(new Foo).get"))->Run(); 154a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block CHECK_EQ(42, result->Int32Value()); 155a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block env->Exit(); 156a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 157a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 158a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 159a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// CodeRange test. 160a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Tests memory management in a CodeRange by allocating and freeing blocks, 161a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// using a pseudorandom generator to choose block sizes geometrically 162a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// distributed between 2 * Page::kPageSize and 2^5 + 1 * Page::kPageSize. 163a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Ensure that the freed chunks are collected and reused by allocating (in 164a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// total) more than the size of the CodeRange. 165a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 166a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// This pseudorandom generator does not need to be particularly good. 167a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Use the lower half of the V8::Random() generator. 168a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockunsigned int Pseudorandom() { 169a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block static uint32_t lo = 2345; 170a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block lo = 18273 * (lo & 0xFFFF) + (lo >> 16); // Provably not 0. 171a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return lo & 0xFFFF; 172a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 173a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 174a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 175a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Plain old data class. Represents a block of allocated memory. 176a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass Block { 177a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public: 178a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Block(void* base_arg, int size_arg) 179a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block : base(base_arg), size(size_arg) {} 180a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 181a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block void *base; 182a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block int size; 183a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block}; 184a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 185a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 186a7e24c173cf37484693b9abb38e494fa7bd7baebSteve BlockTEST(CodeRange) { 187a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block const int code_range_size = 16*MB; 18844f0eee88ff00398ff7f715fab053374d808c90dSteve Block OS::Setup(); 18944f0eee88ff00398ff7f715fab053374d808c90dSteve Block Isolate::Current()->code_range()->Setup(code_range_size); 190a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block int current_allocated = 0; 191a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block int total_allocated = 0; 192a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block List<Block> blocks(1000); 193a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 194a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block while (total_allocated < 5 * code_range_size) { 195a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block if (current_allocated < code_range_size / 10) { 196a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Allocate a block. 197a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Geometrically distributed sizes, greater than Page::kPageSize. 198a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block size_t requested = (Page::kPageSize << (Pseudorandom() % 6)) + 199a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block Pseudorandom() % 5000 + 1; 200a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block size_t allocated = 0; 20144f0eee88ff00398ff7f715fab053374d808c90dSteve Block void* base = Isolate::Current()->code_range()-> 20244f0eee88ff00398ff7f715fab053374d808c90dSteve Block AllocateRawMemory(requested, &allocated); 203d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block blocks.Add(Block(base, static_cast<int>(allocated))); 204d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block current_allocated += static_cast<int>(allocated); 205d0582a6c46733687d045e4188a1bcd0123c758a1Steve Block total_allocated += static_cast<int>(allocated); 206a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block } else { 207a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Free a block. 208a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block int index = Pseudorandom() % blocks.length(); 20944f0eee88ff00398ff7f715fab053374d808c90dSteve Block Isolate::Current()->code_range()->FreeRawMemory( 21044f0eee88ff00398ff7f715fab053374d808c90dSteve Block blocks[index].base, blocks[index].size); 211a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block current_allocated -= blocks[index].size; 212a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block if (index < blocks.length() - 1) { 213a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block blocks[index] = blocks.RemoveLast(); 214a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block } else { 215a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block blocks.RemoveLast(); 216a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block } 217a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block } 218a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block } 219a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 22044f0eee88ff00398ff7f715fab053374d808c90dSteve Block Isolate::Current()->code_range()->TearDown(); 221a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 222