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

Side by Side Diff: src/handles.cc

Issue 4100005: Version 2.5.2 (Closed)
Patch Set: Created 10 years, 1 month 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 "global-handles.h" 37 #include "global-handles.h"
38 #include "natives.h" 38 #include "natives.h"
39 #include "runtime.h" 39 #include "runtime.h"
40 #include "stub-cache.h" 40 #include "stub-cache.h"
41 41
42 namespace v8 { 42 namespace v8 {
43 namespace internal { 43 namespace internal {
44 44
45 45
46 v8::ImplementationUtilities::HandleScopeData HandleScope::current_ = 46 v8::ImplementationUtilities::HandleScopeData HandleScope::current_ =
47 { -1, NULL, NULL }; 47 { NULL, NULL, 0 };
48 48
49 49
50 int HandleScope::NumberOfHandles() { 50 int HandleScope::NumberOfHandles() {
51 int n = HandleScopeImplementer::instance()->blocks()->length(); 51 int n = HandleScopeImplementer::instance()->blocks()->length();
52 if (n == 0) return 0; 52 if (n == 0) return 0;
53 return ((n - 1) * kHandleBlockSize) + static_cast<int>( 53 return ((n - 1) * kHandleBlockSize) + static_cast<int>(
54 (current_.next - HandleScopeImplementer::instance()->blocks()->last())); 54 (current_.next - HandleScopeImplementer::instance()->blocks()->last()));
55 } 55 }
56 56
57 57
58 Object** HandleScope::Extend() { 58 Object** HandleScope::Extend() {
59 Object** result = current_.next; 59 Object** result = current_.next;
60 60
61 ASSERT(result == current_.limit); 61 ASSERT(result == current_.limit);
62 // Make sure there's at least one scope on the stack and that the 62 // Make sure there's at least one scope on the stack and that the
63 // top of the scope stack isn't a barrier. 63 // top of the scope stack isn't a barrier.
64 if (current_.extensions < 0) { 64 if (current_.level == 0) {
65 Utils::ReportApiFailure("v8::HandleScope::CreateHandle()", 65 Utils::ReportApiFailure("v8::HandleScope::CreateHandle()",
66 "Cannot create a handle without a HandleScope"); 66 "Cannot create a handle without a HandleScope");
67 return NULL; 67 return NULL;
68 } 68 }
69 HandleScopeImplementer* impl = HandleScopeImplementer::instance(); 69 HandleScopeImplementer* impl = HandleScopeImplementer::instance();
70 // If there's more room in the last block, we use that. This is used 70 // If there's more room in the last block, we use that. This is used
71 // for fast creation of scopes after scope barriers. 71 // for fast creation of scopes after scope barriers.
72 if (!impl->blocks()->is_empty()) { 72 if (!impl->blocks()->is_empty()) {
73 Object** limit = &impl->blocks()->last()[kHandleBlockSize]; 73 Object** limit = &impl->blocks()->last()[kHandleBlockSize];
74 if (current_.limit != limit) { 74 if (current_.limit != limit) {
75 current_.limit = limit; 75 current_.limit = limit;
76 ASSERT(limit - current_.next < kHandleBlockSize);
76 } 77 }
77 } 78 }
78 79
79 // 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
80 // current handle scope by allocating a new handle block. 81 // current handle scope by allocating a new handle block.
81 if (result == current_.limit) { 82 if (result == current_.limit) {
82 // 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.
83 result = impl->GetSpareOrNewBlock(); 84 result = impl->GetSpareOrNewBlock();
84 // 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
85 // extension as part of the current scope. 86 // extension as part of the current scope.
86 impl->blocks()->Add(result); 87 impl->blocks()->Add(result);
87 current_.extensions++;
88 current_.limit = &result[kHandleBlockSize]; 88 current_.limit = &result[kHandleBlockSize];
89 } 89 }
90 90
91 return result; 91 return result;
92 } 92 }
93 93
94 94
95 void HandleScope::DeleteExtensions() { 95 void HandleScope::DeleteExtensions() {
96 ASSERT(current_.extensions != 0); 96 HandleScopeImplementer::instance()->DeleteExtensions(current_.limit);
97 HandleScopeImplementer::instance()->DeleteExtensions(current_.extensions);
98 } 97 }
99 98
100 99
101 void HandleScope::ZapRange(Object** start, Object** end) { 100 void HandleScope::ZapRange(Object** start, Object** end) {
102 if (start == NULL) return; 101 ASSERT(end - start <= kHandleBlockSize);
103 for (Object** p = start; p < end; p++) { 102 for (Object** p = start; p != end; p++) {
104 *reinterpret_cast<Address*>(p) = v8::internal::kHandleZapValue; 103 *reinterpret_cast<Address*>(p) = v8::internal::kHandleZapValue;
105 } 104 }
106 } 105 }
107 106
108 107
109 Address HandleScope::current_extensions_address() { 108 Address HandleScope::current_level_address() {
110 return reinterpret_cast<Address>(&current_.extensions); 109 return reinterpret_cast<Address>(&current_.level);
111 } 110 }
112 111
113 112
114 Address HandleScope::current_next_address() { 113 Address HandleScope::current_next_address() {
115 return reinterpret_cast<Address>(&current_.next); 114 return reinterpret_cast<Address>(&current_.next);
116 } 115 }
117 116
118 117
119 Address HandleScope::current_limit_address() { 118 Address HandleScope::current_limit_address() {
120 return reinterpret_cast<Address>(&current_.limit); 119 return reinterpret_cast<Address>(&current_.limit);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 202 }
204 203
205 204
206 void TransformToFastProperties(Handle<JSObject> object, 205 void TransformToFastProperties(Handle<JSObject> object,
207 int unused_property_fields) { 206 int unused_property_fields) {
208 CALL_HEAP_FUNCTION_VOID( 207 CALL_HEAP_FUNCTION_VOID(
209 object->TransformToFastProperties(unused_property_fields)); 208 object->TransformToFastProperties(unused_property_fields));
210 } 209 }
211 210
212 211
212 void NumberDictionarySet(Handle<NumberDictionary> dictionary,
213 uint32_t index,
214 Handle<Object> value,
215 PropertyDetails details) {
216 CALL_HEAP_FUNCTION_VOID(dictionary->Set(index, *value, details));
217 }
218
219
213 void FlattenString(Handle<String> string) { 220 void FlattenString(Handle<String> string) {
214 CALL_HEAP_FUNCTION_VOID(string->TryFlatten()); 221 CALL_HEAP_FUNCTION_VOID(string->TryFlatten());
215 } 222 }
216 223
217 224
218 Handle<String> FlattenGetString(Handle<String> string) { 225 Handle<String> FlattenGetString(Handle<String> string) {
219 Handle<String> result; 226 Handle<String> result;
220 CALL_AND_RETRY(string->TryFlatten(), 227 CALL_AND_RETRY(string->TryFlatten(),
221 { result = Handle<String>(String::cast(__object__)); 228 { result = Handle<String>(String::cast(__object__));
222 break; }, 229 break; },
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 864
858 OptimizedObjectForAddingMultipleProperties:: 865 OptimizedObjectForAddingMultipleProperties::
859 ~OptimizedObjectForAddingMultipleProperties() { 866 ~OptimizedObjectForAddingMultipleProperties() {
860 // Reoptimize the object to allow fast property access. 867 // Reoptimize the object to allow fast property access.
861 if (has_been_transformed_) { 868 if (has_been_transformed_) {
862 TransformToFastProperties(object_, unused_property_fields_); 869 TransformToFastProperties(object_, unused_property_fields_);
863 } 870 }
864 } 871 }
865 872
866 } } // namespace v8::internal 873 } } // 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