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

Side by Side Diff: src/handles.cc

Issue 173348: Api inlining. Made some core functionality available in the api and... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 4 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
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void** HandleScope::Extend() { 56 Object** HandleScope::Extend() {
57 void** 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 void** 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);
95 HandleScopeImplementer::instance()->DeleteExtensions(current_.extensions); 95 HandleScopeImplementer::instance()->DeleteExtensions(current_.extensions);
96 } 96 }
97 97
98 98
99 void HandleScope::ZapRange(void** start, void** end) { 99 void HandleScope::ZapRange(Object** start, Object** end) {
100 if (start == NULL) return; 100 if (start == NULL) return;
101 for (void** p = start; p < end; p++) { 101 for (Object** p = start; p < end; p++) {
102 *p = reinterpret_cast<void*>(v8::internal::kHandleZapValue); 102 *reinterpret_cast<Address*>(p) = v8::internal::kHandleZapValue;
103 } 103 }
104 } 104 }
105 105
106 106
107 Handle<FixedArray> AddKeysFromJSArray(Handle<FixedArray> content, 107 Handle<FixedArray> AddKeysFromJSArray(Handle<FixedArray> content,
108 Handle<JSArray> array) { 108 Handle<JSArray> array) {
109 CALL_HEAP_FUNCTION(content->AddKeysFromJSArray(*array), FixedArray); 109 CALL_HEAP_FUNCTION(content->AddKeysFromJSArray(*array), FixedArray);
110 } 110 }
111 111
112 112
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); 758 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map);
759 obj->set_map(*new_map); 759 obj->set_map(*new_map);
760 new_map->set_needs_loading(true); 760 new_map->set_needs_loading(true);
761 // Store the lazy loading info in the constructor field. We'll 761 // Store the lazy loading info in the constructor field. We'll
762 // reestablish the constructor from the fixed array after loading. 762 // reestablish the constructor from the fixed array after loading.
763 new_map->set_constructor(*arr); 763 new_map->set_constructor(*arr);
764 ASSERT(!obj->IsLoaded()); 764 ASSERT(!obj->IsLoaded());
765 } 765 }
766 766
767 } } // namespace v8::internal 767 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698