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

Side by Side Diff: src/heap.cc

Issue 914003: LiveEdit: patch positions in function (Closed)
Patch Set: merge Created 10 years, 9 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
« no previous file with comments | « src/heap.h ('k') | src/liveedit.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 2239 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 reinterpret_cast<Object**>(old_addr), 2250 reinterpret_cast<Object**>(old_addr),
2251 obj_size); 2251 obj_size);
2252 // Relocate the copy. 2252 // Relocate the copy.
2253 Code* new_code = Code::cast(result); 2253 Code* new_code = Code::cast(result);
2254 ASSERT(!CodeRange::exists() || CodeRange::contains(code->address())); 2254 ASSERT(!CodeRange::exists() || CodeRange::contains(code->address()));
2255 new_code->Relocate(new_addr - old_addr); 2255 new_code->Relocate(new_addr - old_addr);
2256 return new_code; 2256 return new_code;
2257 } 2257 }
2258 2258
2259 2259
2260 Object* Heap::CopyCode(Code* code, Vector<byte> reloc_info) {
2261 int new_body_size = RoundUp(code->instruction_size() + reloc_info.length(),
2262 kObjectAlignment);
2263
2264 int sinfo_size = code->sinfo_size();
2265
2266 int new_obj_size = Code::SizeFor(new_body_size, sinfo_size);
2267
2268 Address old_addr = code->address();
2269
2270 int relocation_offset = code->relocation_start() - old_addr;
2271
2272 Object* result;
2273 if (new_obj_size > MaxObjectSizeInPagedSpace()) {
2274 result = lo_space_->AllocateRawCode(new_obj_size);
2275 } else {
2276 result = code_space_->AllocateRaw(new_obj_size);
2277 }
2278
2279 if (result->IsFailure()) return result;
2280
2281 // Copy code object.
2282 Address new_addr = reinterpret_cast<HeapObject*>(result)->address();
2283
2284 // Copy header and instructions.
2285 memcpy(new_addr, old_addr, relocation_offset);
2286
2287 // Copy patched rinfo.
2288 memcpy(new_addr + relocation_offset,
2289 reloc_info.start(),
2290 reloc_info.length());
2291
2292 Code* new_code = Code::cast(result);
2293 new_code->set_relocation_size(reloc_info.length());
2294
2295 // Copy sinfo.
2296 memcpy(new_code->sinfo_start(), code->sinfo_start(), code->sinfo_size());
2297
2298 // Relocate the copy.
2299 ASSERT(!CodeRange::exists() || CodeRange::contains(code->address()));
2300 new_code->Relocate(new_addr - old_addr);
2301
2302 #ifdef DEBUG
2303 code->Verify();
2304 #endif
2305 return new_code;
2306 }
2307
2308
2260 Object* Heap::Allocate(Map* map, AllocationSpace space) { 2309 Object* Heap::Allocate(Map* map, AllocationSpace space) {
2261 ASSERT(gc_state_ == NOT_IN_GC); 2310 ASSERT(gc_state_ == NOT_IN_GC);
2262 ASSERT(map->instance_type() != MAP_TYPE); 2311 ASSERT(map->instance_type() != MAP_TYPE);
2263 // If allocation failures are disallowed, we may allocate in a different 2312 // If allocation failures are disallowed, we may allocate in a different
2264 // space when new space is full and the object is not a large object. 2313 // space when new space is full and the object is not a large object.
2265 AllocationSpace retry_space = 2314 AllocationSpace retry_space =
2266 (space != NEW_SPACE) ? space : TargetSpaceId(map->instance_type()); 2315 (space != NEW_SPACE) ? space : TargetSpaceId(map->instance_type());
2267 Object* result = 2316 Object* result =
2268 AllocateRaw(map->instance_size(), space, retry_space); 2317 AllocateRaw(map->instance_size(), space, retry_space);
2269 if (result->IsFailure()) return result; 2318 if (result->IsFailure()) return result;
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after
4251 void ExternalStringTable::TearDown() { 4300 void ExternalStringTable::TearDown() {
4252 new_space_strings_.Free(); 4301 new_space_strings_.Free();
4253 old_space_strings_.Free(); 4302 old_space_strings_.Free();
4254 } 4303 }
4255 4304
4256 4305
4257 List<Object*> ExternalStringTable::new_space_strings_; 4306 List<Object*> ExternalStringTable::new_space_strings_;
4258 List<Object*> ExternalStringTable::old_space_strings_; 4307 List<Object*> ExternalStringTable::old_space_strings_;
4259 4308
4260 } } // namespace v8::internal 4309 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/liveedit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698