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

Side by Side Diff: src/handles.cc

Issue 251014: * Fix memory leaks caused by thread local data being lost.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 2 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/execution.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 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 28 matching lines...) Expand all
39 39
40 namespace v8 { 40 namespace v8 {
41 namespace internal { 41 namespace internal {
42 42
43 43
44 v8::ImplementationUtilities::HandleScopeData HandleScope::current_ = 44 v8::ImplementationUtilities::HandleScopeData HandleScope::current_ =
45 { -1, NULL, NULL }; 45 { -1, NULL, NULL };
46 46
47 47
48 int HandleScope::NumberOfHandles() { 48 int HandleScope::NumberOfHandles() {
49 int n = HandleScopeImplementer::instance()->Blocks()->length(); 49 int n = HandleScopeImplementer::instance()->blocks()->length();
50 if (n == 0) return 0; 50 if (n == 0) return 0;
51 return ((n - 1) * kHandleBlockSize) + 51 return ((n - 1) * kHandleBlockSize) +
52 (current_.next - HandleScopeImplementer::instance()->Blocks()->last()); 52 (current_.next - HandleScopeImplementer::instance()->blocks()->last());
53 } 53 }
54 54
55 55
56 Object** HandleScope::Extend() { 56 Object** HandleScope::Extend() {
57 Object** result = current_.next; 57 Object** result = current_.next;
58 58
59 ASSERT(result == current_.limit); 59 ASSERT(result == current_.limit);
60 // Make sure there's at least one scope on the stack and that the 60 // Make sure there's at least one scope on the stack and that the
61 // top of the scope stack isn't a barrier. 61 // top of the scope stack isn't a barrier.
62 if (current_.extensions < 0) { 62 if (current_.extensions < 0) {
63 Utils::ReportApiFailure("v8::HandleScope::CreateHandle()", 63 Utils::ReportApiFailure("v8::HandleScope::CreateHandle()",
64 "Cannot create a handle without a HandleScope"); 64 "Cannot create a handle without a HandleScope");
65 return NULL; 65 return NULL;
66 } 66 }
67 HandleScopeImplementer* impl = HandleScopeImplementer::instance(); 67 HandleScopeImplementer* impl = HandleScopeImplementer::instance();
68 // If there's more room in the last block, we use that. This is used 68 // If there's more room in the last block, we use that. This is used
69 // for fast creation of scopes after scope barriers. 69 // for fast creation of scopes after scope barriers.
70 if (!impl->Blocks()->is_empty()) { 70 if (!impl->blocks()->is_empty()) {
71 Object** limit = &impl->Blocks()->last()[kHandleBlockSize]; 71 Object** limit = &impl->blocks()->last()[kHandleBlockSize];
72 if (current_.limit != limit) { 72 if (current_.limit != limit) {
73 current_.limit = limit; 73 current_.limit = limit;
74 } 74 }
75 } 75 }
76 76
77 // If we still haven't found a slot for the handle, we extend the 77 // If we still haven't found a slot for the handle, we extend the
78 // current handle scope by allocating a new handle block. 78 // current handle scope by allocating a new handle block.
79 if (result == current_.limit) { 79 if (result == current_.limit) {
80 // If there's a spare block, use it for growing the current scope. 80 // If there's a spare block, use it for growing the current scope.
81 result = impl->GetSpareOrNewBlock(); 81 result = impl->GetSpareOrNewBlock();
82 // Add the extension to the global list of blocks, but count the 82 // Add the extension to the global list of blocks, but count the
83 // extension as part of the current scope. 83 // extension as part of the current scope.
84 impl->Blocks()->Add(result); 84 impl->blocks()->Add(result);
85 current_.extensions++; 85 current_.extensions++;
86 current_.limit = &result[kHandleBlockSize]; 86 current_.limit = &result[kHandleBlockSize];
87 } 87 }
88 88
89 return result; 89 return result;
90 } 90 }
91 91
92 92
93 void HandleScope::DeleteExtensions() { 93 void HandleScope::DeleteExtensions() {
94 ASSERT(current_.extensions != 0); 94 ASSERT(current_.extensions != 0);
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); 757 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map);
758 obj->set_map(*new_map); 758 obj->set_map(*new_map);
759 new_map->set_needs_loading(true); 759 new_map->set_needs_loading(true);
760 // Store the lazy loading info in the constructor field. We'll 760 // Store the lazy loading info in the constructor field. We'll
761 // reestablish the constructor from the fixed array after loading. 761 // reestablish the constructor from the fixed array after loading.
762 new_map->set_constructor(*arr); 762 new_map->set_constructor(*arr);
763 ASSERT(!obj->IsLoaded()); 763 ASSERT(!obj->IsLoaded());
764 } 764 }
765 765
766 } } // namespace v8::internal 766 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/execution.cc ('k') | src/regexp-stack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698