| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <stdlib.h> | 28 #include <stdlib.h> |
| 29 | 29 |
| 30 #include "v8.h" | 30 #include "v8.h" |
| 31 | 31 |
| 32 #include "global-handles.h" | 32 #include "global-handles.h" |
| 33 #include "snapshot.h" | 33 #include "snapshot.h" |
| 34 #include "top.h" | |
| 35 #include "cctest.h" | 34 #include "cctest.h" |
| 36 | 35 |
| 37 using namespace v8::internal; | 36 using namespace v8::internal; |
| 38 | 37 |
| 39 static v8::Persistent<v8::Context> env; | 38 static v8::Persistent<v8::Context> env; |
| 40 | 39 |
| 41 static void InitializeVM() { | 40 static void InitializeVM() { |
| 42 if (env.IsEmpty()) env = v8::Context::New(); | 41 if (env.IsEmpty()) env = v8::Context::New(); |
| 43 v8::HandleScope scope; | 42 v8::HandleScope scope; |
| 44 env->Enter(); | 43 env->Enter(); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } while (!mapp->IsFailure()); | 165 } while (!mapp->IsFailure()); |
| 167 CHECK(HEAP->CollectGarbage(0, MAP_SPACE)); | 166 CHECK(HEAP->CollectGarbage(0, MAP_SPACE)); |
| 168 mapp = HEAP->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 167 mapp = HEAP->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 169 CHECK(!mapp->IsFailure()); | 168 CHECK(!mapp->IsFailure()); |
| 170 | 169 |
| 171 // allocate a garbage | 170 // allocate a garbage |
| 172 String* func_name = String::cast(HEAP->LookupAsciiSymbol("theFunction")); | 171 String* func_name = String::cast(HEAP->LookupAsciiSymbol("theFunction")); |
| 173 SharedFunctionInfo* function_share = | 172 SharedFunctionInfo* function_share = |
| 174 SharedFunctionInfo::cast(HEAP->AllocateSharedFunctionInfo(func_name)); | 173 SharedFunctionInfo::cast(HEAP->AllocateSharedFunctionInfo(func_name)); |
| 175 JSFunction* function = | 174 JSFunction* function = |
| 176 JSFunction::cast(HEAP->AllocateFunction(*Top::function_map(), | 175 JSFunction::cast(HEAP->AllocateFunction(*Isolate::Current()->function_map(), |
| 177 function_share, | 176 function_share, |
| 178 HEAP->undefined_value())); | 177 HEAP->undefined_value())); |
| 179 Map* initial_map = | 178 Map* initial_map = |
| 180 Map::cast(HEAP->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize)); | 179 Map::cast(HEAP->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize)); |
| 181 function->set_initial_map(initial_map); | 180 function->set_initial_map(initial_map); |
| 182 Top::context()->global()->SetProperty(func_name, function, NONE); | 181 Isolate::Current()->context()->global()->SetProperty(func_name, |
| 182 function, |
| 183 NONE); |
| 183 | 184 |
| 184 JSObject* obj = JSObject::cast(HEAP->AllocateJSObject(function)); | 185 JSObject* obj = JSObject::cast(HEAP->AllocateJSObject(function)); |
| 185 CHECK(HEAP->CollectGarbage(0, OLD_POINTER_SPACE)); | 186 CHECK(HEAP->CollectGarbage(0, OLD_POINTER_SPACE)); |
| 186 | 187 |
| 187 func_name = String::cast(HEAP->LookupAsciiSymbol("theFunction")); | 188 func_name = String::cast(HEAP->LookupAsciiSymbol("theFunction")); |
| 188 CHECK(Top::context()->global()->HasLocalProperty(func_name)); | 189 CHECK(Isolate::Current()->context()->global()->HasLocalProperty(func_name)); |
| 189 Object* func_value = Top::context()->global()->GetProperty(func_name); | 190 Object* func_value = |
| 191 Isolate::Current()->context()->global()->GetProperty(func_name); |
| 190 CHECK(func_value->IsJSFunction()); | 192 CHECK(func_value->IsJSFunction()); |
| 191 function = JSFunction::cast(func_value); | 193 function = JSFunction::cast(func_value); |
| 192 | 194 |
| 193 obj = JSObject::cast(HEAP->AllocateJSObject(function)); | 195 obj = JSObject::cast(HEAP->AllocateJSObject(function)); |
| 194 String* obj_name = String::cast(HEAP->LookupAsciiSymbol("theObject")); | 196 String* obj_name = String::cast(HEAP->LookupAsciiSymbol("theObject")); |
| 195 Top::context()->global()->SetProperty(obj_name, obj, NONE); | 197 Isolate::Current()->context()->global()->SetProperty(obj_name, obj, NONE); |
| 196 String* prop_name = String::cast(HEAP->LookupAsciiSymbol("theSlot")); | 198 String* prop_name = String::cast(HEAP->LookupAsciiSymbol("theSlot")); |
| 197 obj->SetProperty(prop_name, Smi::FromInt(23), NONE); | 199 obj->SetProperty(prop_name, Smi::FromInt(23), NONE); |
| 198 | 200 |
| 199 CHECK(HEAP->CollectGarbage(0, OLD_POINTER_SPACE)); | 201 CHECK(HEAP->CollectGarbage(0, OLD_POINTER_SPACE)); |
| 200 | 202 |
| 201 obj_name = String::cast(HEAP->LookupAsciiSymbol("theObject")); | 203 obj_name = String::cast(HEAP->LookupAsciiSymbol("theObject")); |
| 202 CHECK(Top::context()->global()->HasLocalProperty(obj_name)); | 204 CHECK(Isolate::Current()->context()->global()->HasLocalProperty(obj_name)); |
| 203 CHECK(Top::context()->global()->GetProperty(obj_name)->IsJSObject()); | 205 CHECK(Isolate::Current()->context()->global()->GetProperty(obj_name)-> |
| 204 obj = JSObject::cast(Top::context()->global()->GetProperty(obj_name)); | 206 IsJSObject()); |
| 207 obj = JSObject::cast(Isolate::Current()->context()->global()-> |
| 208 GetProperty(obj_name)); |
| 205 prop_name = String::cast(HEAP->LookupAsciiSymbol("theSlot")); | 209 prop_name = String::cast(HEAP->LookupAsciiSymbol("theSlot")); |
| 206 CHECK(obj->GetProperty(prop_name) == Smi::FromInt(23)); | 210 CHECK(obj->GetProperty(prop_name) == Smi::FromInt(23)); |
| 207 } | 211 } |
| 208 | 212 |
| 209 | 213 |
| 210 static Handle<Map> CreateMap() { | 214 static Handle<Map> CreateMap() { |
| 211 return Factory::NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 215 return Factory::NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 212 } | 216 } |
| 213 | 217 |
| 214 | 218 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; | 336 Object** g2_objects[] = { g2s1.location(), g2s2.location() }; |
| 333 GlobalHandles::AddGroup(g1_objects, 2); | 337 GlobalHandles::AddGroup(g1_objects, 2); |
| 334 GlobalHandles::AddGroup(g2_objects, 2); | 338 GlobalHandles::AddGroup(g2_objects, 2); |
| 335 } | 339 } |
| 336 | 340 |
| 337 CHECK(HEAP->CollectGarbage(0, OLD_POINTER_SPACE)); | 341 CHECK(HEAP->CollectGarbage(0, OLD_POINTER_SPACE)); |
| 338 | 342 |
| 339 // All objects should be gone. 5 global handles in total. | 343 // All objects should be gone. 5 global handles in total. |
| 340 CHECK_EQ(5, NumberOfWeakCalls); | 344 CHECK_EQ(5, NumberOfWeakCalls); |
| 341 } | 345 } |
| OLD | NEW |