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

Side by Side Diff: src/handles.cc

Issue 2476001: Current HandleScope moving to Isolate. (Closed)
Patch Set: removed unnesessary initializing constand, using existing Initialize() for handle scope data. Created 10 years, 6 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/handles.h ('k') | src/handles-inl.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 26 matching lines...) Expand all
37 #include "execution.h" 37 #include "execution.h"
38 #include "global-handles.h" 38 #include "global-handles.h"
39 #include "natives.h" 39 #include "natives.h"
40 #include "runtime.h" 40 #include "runtime.h"
41 #include "stub-cache.h" 41 #include "stub-cache.h"
42 42
43 namespace v8 { 43 namespace v8 {
44 namespace internal { 44 namespace internal {
45 45
46 46
47 v8::ImplementationUtilities::HandleScopeData HandleScope::current_ =
48 { -1, NULL, NULL };
49
50
51 int HandleScope::NumberOfHandles() { 47 int HandleScope::NumberOfHandles() {
52 int n = HandleScopeImplementer::instance()->blocks()->length(); 48 int n = HandleScopeImplementer::instance()->blocks()->length();
53 if (n == 0) return 0; 49 if (n == 0) return 0;
54 return ((n - 1) * kHandleBlockSize) + static_cast<int>( 50 return ((n - 1) * kHandleBlockSize) + static_cast<int>(
55 (current_.next - HandleScopeImplementer::instance()->blocks()->last())); 51 (Isolate::Current()->handle_scope_data()->next -
52 HandleScopeImplementer::instance()->blocks()->last()));
56 } 53 }
57 54
58 55
59 Object** HandleScope::Extend() { 56 Object** HandleScope::Extend() {
60 Object** result = current_.next; 57 v8::ImplementationUtilities::HandleScopeData* current =
58 Isolate::Current()->handle_scope_data();
61 59
62 ASSERT(result == current_.limit); 60 Object** result = current->next;
61
62 ASSERT(result == current->limit);
63 // Make sure there's at least one scope on the stack and that the 63 // Make sure there's at least one scope on the stack and that the
64 // top of the scope stack isn't a barrier. 64 // top of the scope stack isn't a barrier.
65 if (current_.extensions < 0) { 65 if (current->extensions < 0) {
66 Utils::ReportApiFailure("v8::HandleScope::CreateHandle()", 66 Utils::ReportApiFailure("v8::HandleScope::CreateHandle()",
67 "Cannot create a handle without a HandleScope"); 67 "Cannot create a handle without a HandleScope");
68 return NULL; 68 return NULL;
69 } 69 }
70 HandleScopeImplementer* impl = HandleScopeImplementer::instance(); 70 HandleScopeImplementer* impl = HandleScopeImplementer::instance();
71 // If there's more room in the last block, we use that. This is used 71 // If there's more room in the last block, we use that. This is used
72 // for fast creation of scopes after scope barriers. 72 // for fast creation of scopes after scope barriers.
73 if (!impl->blocks()->is_empty()) { 73 if (!impl->blocks()->is_empty()) {
74 Object** limit = &impl->blocks()->last()[kHandleBlockSize]; 74 Object** limit = &impl->blocks()->last()[kHandleBlockSize];
75 if (current_.limit != limit) { 75 if (current->limit != limit) {
76 current_.limit = limit; 76 current->limit = limit;
77 } 77 }
78 } 78 }
79 79
80 // If we still haven't found a slot for the handle, we extend the 80 // If we still haven't found a slot for the handle, we extend the
81 // current handle scope by allocating a new handle block. 81 // current handle scope by allocating a new handle block.
82 if (result == current_.limit) { 82 if (result == current->limit) {
83 // If there's a spare block, use it for growing the current scope. 83 // If there's a spare block, use it for growing the current scope.
84 result = impl->GetSpareOrNewBlock(); 84 result = impl->GetSpareOrNewBlock();
85 // Add the extension to the global list of blocks, but count the 85 // Add the extension to the global list of blocks, but count the
86 // extension as part of the current scope. 86 // extension as part of the current scope.
87 impl->blocks()->Add(result); 87 impl->blocks()->Add(result);
88 current_.extensions++; 88 current->extensions++;
89 current_.limit = &result[kHandleBlockSize]; 89 current->limit = &result[kHandleBlockSize];
90 } 90 }
91 91
92 return result; 92 return result;
93 } 93 }
94 94
95 95
96 void HandleScope::DeleteExtensions() { 96 void HandleScope::DeleteExtensions() {
97 ASSERT(current_.extensions != 0); 97 v8::ImplementationUtilities::HandleScopeData* current =
98 HandleScopeImplementer::instance()->DeleteExtensions(current_.extensions); 98 Isolate::Current()->handle_scope_data();
99
100 ASSERT(current->extensions != 0);
101 HandleScopeImplementer::instance()->DeleteExtensions(current->extensions);
99 } 102 }
100 103
101 104
102 void HandleScope::ZapRange(Object** start, Object** end) { 105 void HandleScope::ZapRange(Object** start, Object** end) {
103 if (start == NULL) return; 106 if (start == NULL) return;
104 for (Object** p = start; p < end; p++) { 107 for (Object** p = start; p < end; p++) {
105 *reinterpret_cast<Address*>(p) = v8::internal::kHandleZapValue; 108 *reinterpret_cast<Address*>(p) = v8::internal::kHandleZapValue;
106 } 109 }
107 } 110 }
108 111
109 112
110 Address HandleScope::current_extensions_address() { 113 Address HandleScope::current_extensions_address() {
111 return reinterpret_cast<Address>(&current_.extensions); 114 return reinterpret_cast<Address>(
115 &Isolate::Current()->handle_scope_data()->extensions);
112 } 116 }
113 117
114 118
115 Address HandleScope::current_next_address() { 119 Address HandleScope::current_next_address() {
116 return reinterpret_cast<Address>(&current_.next); 120 return reinterpret_cast<Address>(
121 &Isolate::Current()->handle_scope_data()->next);
117 } 122 }
118 123
119 124
120 Address HandleScope::current_limit_address() { 125 Address HandleScope::current_limit_address() {
121 return reinterpret_cast<Address>(&current_.limit); 126 return reinterpret_cast<Address>(
127 &Isolate::Current()->handle_scope_data()->limit);
122 } 128 }
123 129
124 130
125 Handle<FixedArray> AddKeysFromJSArray(Handle<FixedArray> content, 131 Handle<FixedArray> AddKeysFromJSArray(Handle<FixedArray> content,
126 Handle<JSArray> array) { 132 Handle<JSArray> array) {
127 CALL_HEAP_FUNCTION(content->AddKeysFromJSArray(*array), FixedArray); 133 CALL_HEAP_FUNCTION(content->AddKeysFromJSArray(*array), FixedArray);
128 } 134 }
129 135
130 136
131 Handle<FixedArray> UnionOfKeys(Handle<FixedArray> first, 137 Handle<FixedArray> UnionOfKeys(Handle<FixedArray> first,
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 808
803 OptimizedObjectForAddingMultipleProperties:: 809 OptimizedObjectForAddingMultipleProperties::
804 ~OptimizedObjectForAddingMultipleProperties() { 810 ~OptimizedObjectForAddingMultipleProperties() {
805 // Reoptimize the object to allow fast property access. 811 // Reoptimize the object to allow fast property access.
806 if (has_been_transformed_) { 812 if (has_been_transformed_) {
807 TransformToFastProperties(object_, unused_property_fields_); 813 TransformToFastProperties(object_, unused_property_fields_);
808 } 814 }
809 } 815 }
810 816
811 } } // namespace v8::internal 817 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/handles.h ('k') | src/handles-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698