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

Side by Side Diff: src/handles.cc

Issue 12300018: Made Isolate a mandatory parameter for everything Handle-related. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed CreateCode calls. Be nicer to MIPS. Created 7 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 | Annotate | Revision Log
« 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 27 matching lines...) Expand all
38 #include "natives.h" 38 #include "natives.h"
39 #include "runtime.h" 39 #include "runtime.h"
40 #include "string-search.h" 40 #include "string-search.h"
41 #include "stub-cache.h" 41 #include "stub-cache.h"
42 #include "vm-state-inl.h" 42 #include "vm-state-inl.h"
43 43
44 namespace v8 { 44 namespace v8 {
45 namespace internal { 45 namespace internal {
46 46
47 47
48 int HandleScope::NumberOfHandles() { 48 int HandleScope::NumberOfHandles(Isolate* isolate) {
49 Isolate* isolate = Isolate::Current();
50 HandleScopeImplementer* impl = isolate->handle_scope_implementer(); 49 HandleScopeImplementer* impl = isolate->handle_scope_implementer();
51 int n = impl->blocks()->length(); 50 int n = impl->blocks()->length();
52 if (n == 0) return 0; 51 if (n == 0) return 0;
53 return ((n - 1) * kHandleBlockSize) + static_cast<int>( 52 return ((n - 1) * kHandleBlockSize) + static_cast<int>(
54 (isolate->handle_scope_data()->next - impl->blocks()->last())); 53 (isolate->handle_scope_data()->next - impl->blocks()->last()));
55 } 54 }
56 55
57 56
58 Object** HandleScope::Extend() { 57 Object** HandleScope::Extend(Isolate* isolate) {
59 Isolate* isolate = Isolate::Current();
60 v8::ImplementationUtilities::HandleScopeData* current = 58 v8::ImplementationUtilities::HandleScopeData* current =
61 isolate->handle_scope_data(); 59 isolate->handle_scope_data();
62 60
63 Object** result = current->next; 61 Object** result = current->next;
64 62
65 ASSERT(result == current->limit); 63 ASSERT(result == current->limit);
66 // Make sure there's at least one scope on the stack and that the 64 // Make sure there's at least one scope on the stack and that the
67 // top of the scope stack isn't a barrier. 65 // top of the scope stack isn't a barrier.
68 if (current->level == 0) { 66 if (current->level == 0) {
69 Utils::ReportApiFailure("v8::HandleScope::CreateHandle()", 67 Utils::ReportApiFailure("v8::HandleScope::CreateHandle()",
(...skipping 20 matching lines...) Expand all
90 // extension as part of the current scope. 88 // extension as part of the current scope.
91 impl->blocks()->Add(result); 89 impl->blocks()->Add(result);
92 current->limit = &result[kHandleBlockSize]; 90 current->limit = &result[kHandleBlockSize];
93 } 91 }
94 92
95 return result; 93 return result;
96 } 94 }
97 95
98 96
99 void HandleScope::DeleteExtensions(Isolate* isolate) { 97 void HandleScope::DeleteExtensions(Isolate* isolate) {
100 ASSERT(isolate == Isolate::Current());
101 v8::ImplementationUtilities::HandleScopeData* current = 98 v8::ImplementationUtilities::HandleScopeData* current =
102 isolate->handle_scope_data(); 99 isolate->handle_scope_data();
103 isolate->handle_scope_implementer()->DeleteExtensions(current->limit); 100 isolate->handle_scope_implementer()->DeleteExtensions(current->limit);
104 } 101 }
105 102
106 103
107 void HandleScope::ZapRange(Object** start, Object** end) { 104 void HandleScope::ZapRange(Object** start, Object** end) {
108 ASSERT(end - start <= kHandleBlockSize); 105 ASSERT(end - start <= kHandleBlockSize);
109 for (Object** p = start; p != end; p++) { 106 for (Object** p = start; p != end; p++) {
110 *reinterpret_cast<Address*>(p) = v8::internal::kHandleZapValue; 107 *reinterpret_cast<Address*>(p) = v8::internal::kHandleZapValue;
111 } 108 }
112 } 109 }
113 110
114 111
115 Address HandleScope::current_level_address() { 112 Address HandleScope::current_level_address(Isolate* isolate) {
116 return reinterpret_cast<Address>( 113 return reinterpret_cast<Address>(&isolate->handle_scope_data()->level);
117 &Isolate::Current()->handle_scope_data()->level);
118 } 114 }
119 115
120 116
121 Address HandleScope::current_next_address() { 117 Address HandleScope::current_next_address(Isolate* isolate) {
122 return reinterpret_cast<Address>( 118 return reinterpret_cast<Address>(&isolate->handle_scope_data()->next);
123 &Isolate::Current()->handle_scope_data()->next);
124 } 119 }
125 120
126 121
127 Address HandleScope::current_limit_address() { 122 Address HandleScope::current_limit_address(Isolate* isolate) {
128 return reinterpret_cast<Address>( 123 return reinterpret_cast<Address>(&isolate->handle_scope_data()->limit);
129 &Isolate::Current()->handle_scope_data()->limit);
130 } 124 }
131 125
132 126
133 Handle<FixedArray> AddKeysFromJSArray(Handle<FixedArray> content, 127 Handle<FixedArray> AddKeysFromJSArray(Handle<FixedArray> content,
134 Handle<JSArray> array) { 128 Handle<JSArray> array) {
135 CALL_HEAP_FUNCTION(content->GetIsolate(), 129 CALL_HEAP_FUNCTION(content->GetIsolate(),
136 content->AddKeysFromJSArray(*array), FixedArray); 130 content->AddKeysFromJSArray(*array), FixedArray);
137 } 131 }
138 132
139 133
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 274
281 275
282 Handle<Object> GetProperty(Handle<JSReceiver> obj, 276 Handle<Object> GetProperty(Handle<JSReceiver> obj,
283 const char* name) { 277 const char* name) {
284 Isolate* isolate = obj->GetIsolate(); 278 Isolate* isolate = obj->GetIsolate();
285 Handle<String> str = isolate->factory()->LookupUtf8Symbol(name); 279 Handle<String> str = isolate->factory()->LookupUtf8Symbol(name);
286 CALL_HEAP_FUNCTION(isolate, obj->GetProperty(*str), Object); 280 CALL_HEAP_FUNCTION(isolate, obj->GetProperty(*str), Object);
287 } 281 }
288 282
289 283
290 Handle<Object> GetProperty(Handle<Object> obj, 284 Handle<Object> GetProperty(Isolate* isolate,
285 Handle<Object> obj,
291 Handle<Object> key) { 286 Handle<Object> key) {
292 Isolate* isolate = Isolate::Current();
293 CALL_HEAP_FUNCTION(isolate, 287 CALL_HEAP_FUNCTION(isolate,
294 Runtime::GetObjectProperty(isolate, obj, key), Object); 288 Runtime::GetObjectProperty(isolate, obj, key), Object);
295 } 289 }
296 290
297 291
298 Handle<Object> GetPropertyWithInterceptor(Handle<JSObject> receiver, 292 Handle<Object> GetPropertyWithInterceptor(Handle<JSObject> receiver,
299 Handle<JSObject> holder, 293 Handle<JSObject> holder,
300 Handle<String> name, 294 Handle<String> name,
301 PropertyAttributes* attributes) { 295 PropertyAttributes* attributes) {
302 Isolate* isolate = receiver->GetIsolate(); 296 Isolate* isolate = receiver->GetIsolate();
303 CALL_HEAP_FUNCTION(isolate, 297 CALL_HEAP_FUNCTION(isolate,
304 holder->GetPropertyWithInterceptor(*receiver, 298 holder->GetPropertyWithInterceptor(*receiver,
305 *name, 299 *name,
306 attributes), 300 attributes),
307 Object); 301 Object);
308 } 302 }
309 303
310 304
311 Handle<Object> SetPrototype(Handle<JSObject> obj, Handle<Object> value) { 305 Handle<Object> SetPrototype(Handle<JSObject> obj, Handle<Object> value) {
312 const bool skip_hidden_prototypes = false; 306 const bool skip_hidden_prototypes = false;
313 CALL_HEAP_FUNCTION(obj->GetIsolate(), 307 CALL_HEAP_FUNCTION(obj->GetIsolate(),
314 obj->SetPrototype(*value, skip_hidden_prototypes), Object); 308 obj->SetPrototype(*value, skip_hidden_prototypes), Object);
315 } 309 }
316 310
317 311
318 Handle<Object> LookupSingleCharacterStringFromCode(uint32_t index) { 312 Handle<Object> LookupSingleCharacterStringFromCode(Isolate* isolate,
319 Isolate* isolate = Isolate::Current(); 313 uint32_t index) {
320 CALL_HEAP_FUNCTION( 314 CALL_HEAP_FUNCTION(
321 isolate, 315 isolate,
322 isolate->heap()->LookupSingleCharacterStringFromCode(index), Object); 316 isolate->heap()->LookupSingleCharacterStringFromCode(index), Object);
323 } 317 }
324 318
325 319
326 Handle<String> SubString(Handle<String> str, 320 Handle<String> SubString(Handle<String> str,
327 int start, 321 int start,
328 int end, 322 int end,
329 PretenureFlag pretenure) { 323 PretenureFlag pretenure) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 isolate->counters()->script_wrappers()->Decrement(); 358 isolate->counters()->script_wrappers()->Decrement();
365 } 359 }
366 360
367 361
368 Handle<JSValue> GetScriptWrapper(Handle<Script> script) { 362 Handle<JSValue> GetScriptWrapper(Handle<Script> script) {
369 if (script->wrapper()->foreign_address() != NULL) { 363 if (script->wrapper()->foreign_address() != NULL) {
370 // Return the script wrapper directly from the cache. 364 // Return the script wrapper directly from the cache.
371 return Handle<JSValue>( 365 return Handle<JSValue>(
372 reinterpret_cast<JSValue**>(script->wrapper()->foreign_address())); 366 reinterpret_cast<JSValue**>(script->wrapper()->foreign_address()));
373 } 367 }
374 Isolate* isolate = Isolate::Current(); 368 Isolate* isolate = script->GetIsolate();
375 // Construct a new script wrapper. 369 // Construct a new script wrapper.
376 isolate->counters()->script_wrappers()->Increment(); 370 isolate->counters()->script_wrappers()->Increment();
377 Handle<JSFunction> constructor = isolate->script_function(); 371 Handle<JSFunction> constructor = isolate->script_function();
378 Handle<JSValue> result = 372 Handle<JSValue> result =
379 Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor)); 373 Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor));
380 374
381 // The allocation might have triggered a GC, which could have called this 375 // The allocation might have triggered a GC, which could have called this
382 // function recursively, and a wrapper has already been created and cached. 376 // function recursively, and a wrapper has already been created and cached.
383 // In that case, simply return the cached wrapper. 377 // In that case, simply return the cached wrapper.
384 if (script->wrapper()->foreign_address() != NULL) { 378 if (script->wrapper()->foreign_address() != NULL) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 return result; 599 return result;
606 } 600 }
607 601
608 602
609 Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) { 603 Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) {
610 Isolate* isolate = script->GetIsolate(); 604 Isolate* isolate = script->GetIsolate();
611 Handle<String> name_or_source_url_key = 605 Handle<String> name_or_source_url_key =
612 isolate->factory()->LookupOneByteSymbol( 606 isolate->factory()->LookupOneByteSymbol(
613 STATIC_ASCII_VECTOR("nameOrSourceURL")); 607 STATIC_ASCII_VECTOR("nameOrSourceURL"));
614 Handle<JSValue> script_wrapper = GetScriptWrapper(script); 608 Handle<JSValue> script_wrapper = GetScriptWrapper(script);
615 Handle<Object> property = GetProperty(script_wrapper, 609 Handle<Object> property = GetProperty(isolate,
610 script_wrapper,
616 name_or_source_url_key); 611 name_or_source_url_key);
617 ASSERT(property->IsJSFunction()); 612 ASSERT(property->IsJSFunction());
618 Handle<JSFunction> method = Handle<JSFunction>::cast(property); 613 Handle<JSFunction> method = Handle<JSFunction>::cast(property);
619 bool caught_exception; 614 bool caught_exception;
620 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0, 615 Handle<Object> result = Execution::TryCall(method, script_wrapper, 0,
621 NULL, &caught_exception); 616 NULL, &caught_exception);
622 if (caught_exception) { 617 if (caught_exception) {
623 result = isolate->factory()->undefined_value(); 618 result = isolate->factory()->undefined_value();
624 } 619 }
625 return result; 620 return result;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 Handle<Object> key, 886 Handle<Object> key,
892 Handle<Object> value) { 887 Handle<Object> value) {
893 CALL_HEAP_FUNCTION(table->GetIsolate(), 888 CALL_HEAP_FUNCTION(table->GetIsolate(),
894 table->Put(*key, *value), 889 table->Put(*key, *value),
895 ObjectHashTable); 890 ObjectHashTable);
896 } 891 }
897 892
898 893
899 DeferredHandleScope::DeferredHandleScope(Isolate* isolate) 894 DeferredHandleScope::DeferredHandleScope(Isolate* isolate)
900 : impl_(isolate->handle_scope_implementer()) { 895 : impl_(isolate->handle_scope_implementer()) {
901 ASSERT(impl_->isolate() == Isolate::Current());
902 impl_->BeginDeferredScope(); 896 impl_->BeginDeferredScope();
903 v8::ImplementationUtilities::HandleScopeData* data = 897 v8::ImplementationUtilities::HandleScopeData* data =
904 impl_->isolate()->handle_scope_data(); 898 impl_->isolate()->handle_scope_data();
905 Object** new_next = impl_->GetSpareOrNewBlock(); 899 Object** new_next = impl_->GetSpareOrNewBlock();
906 Object** new_limit = &new_next[kHandleBlockSize]; 900 Object** new_limit = &new_next[kHandleBlockSize];
907 ASSERT(data->limit == &impl_->blocks()->last()[kHandleBlockSize]); 901 ASSERT(data->limit == &impl_->blocks()->last()[kHandleBlockSize]);
908 impl_->blocks()->Add(new_next); 902 impl_->blocks()->Add(new_next);
909 903
910 #ifdef DEBUG 904 #ifdef DEBUG
911 prev_level_ = data->level; 905 prev_level_ = data->level;
(...skipping 20 matching lines...) Expand all
932 data->next = prev_next_; 926 data->next = prev_next_;
933 data->limit = prev_limit_; 927 data->limit = prev_limit_;
934 #ifdef DEBUG 928 #ifdef DEBUG
935 handles_detached_ = true; 929 handles_detached_ = true;
936 #endif 930 #endif
937 return deferred; 931 return deferred;
938 } 932 }
939 933
940 934
941 } } // namespace v8::internal 935 } } // 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