 Chromium Code Reviews
 Chromium Code Reviews Issue 211333002:
  Replace HeapNumber as doublebox with an explicit MutableHeapNumber.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 211333002:
  Replace HeapNumber as doublebox with an explicit MutableHeapNumber.  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| OLD | NEW | 
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1595 } | 1595 } | 
| 1596 CHECK_EQ(1, count); | 1596 CHECK_EQ(1, count); | 
| 1597 } | 1597 } | 
| 1598 | 1598 | 
| 1599 | 1599 | 
| 1600 TEST(GetHeapValueForNode) { | 1600 TEST(GetHeapValueForNode) { | 
| 1601 LocalContext env; | 1601 LocalContext env; | 
| 1602 v8::HandleScope scope(env->GetIsolate()); | 1602 v8::HandleScope scope(env->GetIsolate()); | 
| 1603 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 1603 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 
| 1604 | 1604 | 
| 1605 CompileRun("a = { s_prop: \'value\', n_prop: 0.1 };"); | 1605 CompileRun("a = { s_prop: \'value\', n_prop: \'value2\' };"); | 
| 1606 const v8::HeapSnapshot* snapshot = | 1606 const v8::HeapSnapshot* snapshot = | 
| 1607 heap_profiler->TakeHeapSnapshot(v8_str("value")); | 1607 heap_profiler->TakeHeapSnapshot(v8_str("value")); | 
| 1608 CHECK(ValidateSnapshot(snapshot)); | 1608 CHECK(ValidateSnapshot(snapshot)); | 
| 1609 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); | 1609 const v8::HeapGraphNode* global = GetGlobalObject(snapshot); | 
| 1610 CHECK(heap_profiler->FindObjectById(global->GetId())->IsObject()); | 1610 CHECK(heap_profiler->FindObjectById(global->GetId())->IsObject()); | 
| 1611 v8::Local<v8::Object> js_global = | 1611 v8::Local<v8::Object> js_global = | 
| 1612 env->Global()->GetPrototype().As<v8::Object>(); | 1612 env->Global()->GetPrototype().As<v8::Object>(); | 
| 1613 CHECK(js_global == heap_profiler->FindObjectById(global->GetId())); | 1613 CHECK(js_global == heap_profiler->FindObjectById(global->GetId())); | 
| 1614 const v8::HeapGraphNode* obj = GetProperty( | 1614 const v8::HeapGraphNode* obj = GetProperty( | 
| 1615 global, v8::HeapGraphEdge::kProperty, "a"); | 1615 global, v8::HeapGraphEdge::kProperty, "a"); | 
| 1616 CHECK(heap_profiler->FindObjectById(obj->GetId())->IsObject()); | 1616 CHECK(heap_profiler->FindObjectById(obj->GetId())->IsObject()); | 
| 1617 v8::Local<v8::Object> js_obj = js_global->Get(v8_str("a")).As<v8::Object>(); | 1617 v8::Local<v8::Object> js_obj = js_global->Get(v8_str("a")).As<v8::Object>(); | 
| 1618 CHECK(js_obj == heap_profiler->FindObjectById(obj->GetId())); | 1618 CHECK(js_obj == heap_profiler->FindObjectById(obj->GetId())); | 
| 1619 const v8::HeapGraphNode* s_prop = | 1619 const v8::HeapGraphNode* s_prop = | 
| 1620 GetProperty(obj, v8::HeapGraphEdge::kProperty, "s_prop"); | 1620 GetProperty(obj, v8::HeapGraphEdge::kProperty, "s_prop"); | 
| 1621 v8::Local<v8::String> js_s_prop = | 1621 v8::Local<v8::String> js_s_prop = | 
| 1622 js_obj->Get(v8_str("s_prop")).As<v8::String>(); | 1622 js_obj->Get(v8_str("s_prop")).As<v8::String>(); | 
| 1623 CHECK(js_s_prop == heap_profiler->FindObjectById(s_prop->GetId())); | 1623 CHECK(js_s_prop == heap_profiler->FindObjectById(s_prop->GetId())); | 
| 1624 const v8::HeapGraphNode* n_prop = | 1624 const v8::HeapGraphNode* n_prop = | 
| 1625 GetProperty(obj, v8::HeapGraphEdge::kProperty, "n_prop"); | 1625 GetProperty(obj, v8::HeapGraphEdge::kProperty, "n_prop"); | 
| 1626 v8::Local<v8::Number> js_n_prop = | 1626 v8::Local<v8::String> js_n_prop = | 
| 1627 js_obj->Get(v8_str("n_prop")).As<v8::Number>(); | 1627 js_obj->Get(v8_str("n_prop")).As<v8::String>(); | 
| 1628 CHECK(js_n_prop->NumberValue() == | 1628 CHECK(js_n_prop == heap_profiler->FindObjectById(n_prop->GetId())); | 
| 
Igor Sheludko
2014/03/31 11:19:05
Probably it would be less confusing to check that
 | |
| 1629 heap_profiler->FindObjectById(n_prop->GetId())->NumberValue()); | |
| 1630 } | 1629 } | 
| 1631 | 1630 | 
| 1632 | 1631 | 
| 1633 TEST(GetHeapValueForDeletedObject) { | 1632 TEST(GetHeapValueForDeletedObject) { | 
| 1634 LocalContext env; | 1633 LocalContext env; | 
| 1635 v8::HandleScope scope(env->GetIsolate()); | 1634 v8::HandleScope scope(env->GetIsolate()); | 
| 1636 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 1635 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); | 
| 1637 | 1636 | 
| 1638 // It is impossible to delete a global property, so we are about to delete a | 1637 // It is impossible to delete a global property, so we are about to delete a | 
| 1639 // property of the "a" object. Also, the "p" object can't be an empty one | 1638 // property of the "a" object. Also, the "p" object can't be an empty one | 
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2559 map.AddRange(ToAddress(0x180), 0x80, 6U); | 2558 map.AddRange(ToAddress(0x180), 0x80, 6U); | 
| 2560 map.AddRange(ToAddress(0x180), 0x80, 7U); | 2559 map.AddRange(ToAddress(0x180), 0x80, 7U); | 
| 2561 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); | 2560 CHECK_EQ(7, map.GetTraceNodeId(ToAddress(0x180))); | 
| 2562 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); | 2561 CHECK_EQ(5, map.GetTraceNodeId(ToAddress(0x200))); | 
| 2563 CHECK_EQ(3, static_cast<int>(map.size())); | 2562 CHECK_EQ(3, static_cast<int>(map.size())); | 
| 2564 | 2563 | 
| 2565 map.Clear(); | 2564 map.Clear(); | 
| 2566 CHECK_EQ(0, static_cast<int>(map.size())); | 2565 CHECK_EQ(0, static_cast<int>(map.size())); | 
| 2567 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); | 2566 CHECK_EQ(0, map.GetTraceNodeId(ToAddress(0x400))); | 
| 2568 } | 2567 } | 
| OLD | NEW |