| OLD | NEW |
| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 void FlattenString(Handle<String> string) { | 153 void FlattenString(Handle<String> string) { |
| 154 CALL_HEAP_FUNCTION_VOID(string->GetIsolate(), string->TryFlatten()); | 154 CALL_HEAP_FUNCTION_VOID(string->GetIsolate(), string->TryFlatten()); |
| 155 } | 155 } |
| 156 | 156 |
| 157 | 157 |
| 158 Handle<String> FlattenGetString(Handle<String> string) { | 158 Handle<String> FlattenGetString(Handle<String> string) { |
| 159 CALL_HEAP_FUNCTION(string->GetIsolate(), string->TryFlatten(), String); | 159 CALL_HEAP_FUNCTION(string->GetIsolate(), string->TryFlatten(), String); |
| 160 } | 160 } |
| 161 | 161 |
| 162 | 162 |
| 163 Handle<Object> SetProperty(Isolate* isolate, | |
| 164 Handle<Object> object, | |
| 165 Handle<Object> key, | |
| 166 Handle<Object> value, | |
| 167 PropertyAttributes attributes, | |
| 168 StrictModeFlag strict_mode) { | |
| 169 CALL_HEAP_FUNCTION( | |
| 170 isolate, | |
| 171 Runtime::SetObjectProperty( | |
| 172 isolate, object, key, value, attributes, strict_mode), | |
| 173 Object); | |
| 174 } | |
| 175 | |
| 176 | |
| 177 Handle<Object> ForceSetProperty(Handle<JSObject> object, | 163 Handle<Object> ForceSetProperty(Handle<JSObject> object, |
| 178 Handle<Object> key, | 164 Handle<Object> key, |
| 179 Handle<Object> value, | 165 Handle<Object> value, |
| 180 PropertyAttributes attributes) { | 166 PropertyAttributes attributes) { |
| 181 Isolate* isolate = object->GetIsolate(); | 167 return Runtime::ForceSetObjectProperty(object->GetIsolate(), object, key, |
| 182 CALL_HEAP_FUNCTION( | 168 value, attributes); |
| 183 isolate, | |
| 184 Runtime::ForceSetObjectProperty( | |
| 185 isolate, object, key, value, attributes), | |
| 186 Object); | |
| 187 } | 169 } |
| 188 | 170 |
| 189 | 171 |
| 190 Handle<Object> DeleteProperty(Handle<JSObject> object, Handle<Object> key) { | 172 Handle<Object> DeleteProperty(Handle<JSObject> object, Handle<Object> key) { |
| 191 Isolate* isolate = object->GetIsolate(); | 173 Isolate* isolate = object->GetIsolate(); |
| 192 CALL_HEAP_FUNCTION(isolate, | 174 CALL_HEAP_FUNCTION(isolate, |
| 193 Runtime::DeleteObjectProperty( | 175 Runtime::DeleteObjectProperty( |
| 194 isolate, object, key, JSReceiver::NORMAL_DELETION), | 176 isolate, object, key, JSReceiver::NORMAL_DELETION), |
| 195 Object); | 177 Object); |
| 196 } | 178 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 reinterpret_cast<Address>(cache.location())); | 235 reinterpret_cast<Address>(cache.location())); |
| 254 foreign->set_foreign_address(0); | 236 foreign->set_foreign_address(0); |
| 255 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 237 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
| 256 isolate->global_handles()->Destroy(cache.location()); | 238 isolate->global_handles()->Destroy(cache.location()); |
| 257 isolate->counters()->script_wrappers()->Decrement(); | 239 isolate->counters()->script_wrappers()->Decrement(); |
| 258 } | 240 } |
| 259 | 241 |
| 260 | 242 |
| 261 Handle<JSValue> GetScriptWrapper(Handle<Script> script) { | 243 Handle<JSValue> GetScriptWrapper(Handle<Script> script) { |
| 262 if (script->wrapper()->foreign_address() != NULL) { | 244 if (script->wrapper()->foreign_address() != NULL) { |
| 263 // Return the script wrapper directly from the cache. | 245 // Return a handle for the existing script wrapper from the cache. |
| 264 return Handle<JSValue>( | 246 return Handle<JSValue>( |
| 265 reinterpret_cast<JSValue**>(script->wrapper()->foreign_address())); | 247 *reinterpret_cast<JSValue**>(script->wrapper()->foreign_address())); |
| 266 } | 248 } |
| 267 Isolate* isolate = script->GetIsolate(); | 249 Isolate* isolate = script->GetIsolate(); |
| 268 // Construct a new script wrapper. | 250 // Construct a new script wrapper. |
| 269 isolate->counters()->script_wrappers()->Increment(); | 251 isolate->counters()->script_wrappers()->Increment(); |
| 270 Handle<JSFunction> constructor = isolate->script_function(); | 252 Handle<JSFunction> constructor = isolate->script_function(); |
| 271 Handle<JSValue> result = | 253 Handle<JSValue> result = |
| 272 Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor)); | 254 Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor)); |
| 273 | 255 |
| 274 // The allocation might have triggered a GC, which could have called this | 256 // The allocation might have triggered a GC, which could have called this |
| 275 // function recursively, and a wrapper has already been created and cached. | 257 // function recursively, and a wrapper has already been created and cached. |
| 276 // In that case, simply return the cached wrapper. | 258 // In that case, simply return a handle for the cached wrapper. |
| 277 if (script->wrapper()->foreign_address() != NULL) { | 259 if (script->wrapper()->foreign_address() != NULL) { |
| 278 return Handle<JSValue>( | 260 return Handle<JSValue>( |
| 279 reinterpret_cast<JSValue**>(script->wrapper()->foreign_address())); | 261 *reinterpret_cast<JSValue**>(script->wrapper()->foreign_address())); |
| 280 } | 262 } |
| 281 | 263 |
| 282 result->set_value(*script); | 264 result->set_value(*script); |
| 283 | 265 |
| 284 // Create a new weak global handle and use it to cache the wrapper | 266 // Create a new weak global handle and use it to cache the wrapper |
| 285 // for future use. The cache will automatically be cleared by the | 267 // for future use. The cache will automatically be cleared by the |
| 286 // garbage collector when it is not used anymore. | 268 // garbage collector when it is not used anymore. |
| 287 Handle<Object> handle = isolate->global_handles()->Create(*result); | 269 Handle<Object> handle = isolate->global_handles()->Create(*result); |
| 288 isolate->global_handles()->MakeWeak(handle.location(), | 270 isolate->global_handles()->MakeWeak(handle.location(), |
| 289 NULL, | 271 NULL, |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 Handle<FixedArray> storage = | 742 Handle<FixedArray> storage = |
| 761 isolate->factory()->NewFixedArray(next_enumeration); | 743 isolate->factory()->NewFixedArray(next_enumeration); |
| 762 | 744 |
| 763 storage = Handle<FixedArray>(dictionary->CopyEnumKeysTo(*storage)); | 745 storage = Handle<FixedArray>(dictionary->CopyEnumKeysTo(*storage)); |
| 764 ASSERT(storage->length() == object->NumberOfLocalProperties(DONT_SHOW)); | 746 ASSERT(storage->length() == object->NumberOfLocalProperties(DONT_SHOW)); |
| 765 return storage; | 747 return storage; |
| 766 } | 748 } |
| 767 } | 749 } |
| 768 | 750 |
| 769 | 751 |
| 770 Handle<ObjectHashSet> ObjectHashSetAdd(Handle<ObjectHashSet> table, | |
| 771 Handle<Object> key) { | |
| 772 CALL_HEAP_FUNCTION(table->GetIsolate(), | |
| 773 table->Add(*key), | |
| 774 ObjectHashSet); | |
| 775 } | |
| 776 | |
| 777 | |
| 778 Handle<ObjectHashSet> ObjectHashSetRemove(Handle<ObjectHashSet> table, | |
| 779 Handle<Object> key) { | |
| 780 CALL_HEAP_FUNCTION(table->GetIsolate(), | |
| 781 table->Remove(*key), | |
| 782 ObjectHashSet); | |
| 783 } | |
| 784 | |
| 785 | |
| 786 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table, | |
| 787 Handle<Object> key, | |
| 788 Handle<Object> value) { | |
| 789 CALL_HEAP_FUNCTION(table->GetIsolate(), | |
| 790 table->Put(*key, *value), | |
| 791 ObjectHashTable); | |
| 792 } | |
| 793 | |
| 794 | |
| 795 DeferredHandleScope::DeferredHandleScope(Isolate* isolate) | 752 DeferredHandleScope::DeferredHandleScope(Isolate* isolate) |
| 796 : impl_(isolate->handle_scope_implementer()) { | 753 : impl_(isolate->handle_scope_implementer()) { |
| 797 impl_->BeginDeferredScope(); | 754 impl_->BeginDeferredScope(); |
| 798 v8::ImplementationUtilities::HandleScopeData* data = | 755 v8::ImplementationUtilities::HandleScopeData* data = |
| 799 impl_->isolate()->handle_scope_data(); | 756 impl_->isolate()->handle_scope_data(); |
| 800 Object** new_next = impl_->GetSpareOrNewBlock(); | 757 Object** new_next = impl_->GetSpareOrNewBlock(); |
| 801 Object** new_limit = &new_next[kHandleBlockSize]; | 758 Object** new_limit = &new_next[kHandleBlockSize]; |
| 802 ASSERT(data->limit == &impl_->blocks()->last()[kHandleBlockSize]); | 759 ASSERT(data->limit == &impl_->blocks()->last()[kHandleBlockSize]); |
| 803 impl_->blocks()->Add(new_next); | 760 impl_->blocks()->Add(new_next); |
| 804 | 761 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 Handle<Code> code) { | 795 Handle<Code> code) { |
| 839 heap->EnsureWeakObjectToCodeTable(); | 796 heap->EnsureWeakObjectToCodeTable(); |
| 840 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object)); | 797 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object)); |
| 841 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code); | 798 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code); |
| 842 CALL_HEAP_FUNCTION_VOID(heap->isolate(), | 799 CALL_HEAP_FUNCTION_VOID(heap->isolate(), |
| 843 heap->AddWeakObjectToCodeDependency(*object, *dep)); | 800 heap->AddWeakObjectToCodeDependency(*object, *dep)); |
| 844 } | 801 } |
| 845 | 802 |
| 846 | 803 |
| 847 } } // namespace v8::internal | 804 } } // namespace v8::internal |
| OLD | NEW |