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

Side by Side Diff: test/cctest/test-mementos.cc

Issue 292433016: Revert "Reland r21346 "Inobject slack tracking is done on a per-closure basis instead of per-shared… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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/x64/builtins-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 TEST(PretenuringCallNew) { 83 TEST(PretenuringCallNew) {
84 CcTest::InitializeVM(); 84 CcTest::InitializeVM();
85 if (!i::FLAG_allocation_site_pretenuring) return; 85 if (!i::FLAG_allocation_site_pretenuring) return;
86 if (!i::FLAG_pretenuring_call_new) return; 86 if (!i::FLAG_pretenuring_call_new) return;
87 87
88 v8::HandleScope scope(CcTest::isolate()); 88 v8::HandleScope scope(CcTest::isolate());
89 Isolate* isolate = CcTest::i_isolate(); 89 Isolate* isolate = CcTest::i_isolate();
90 Heap* heap = isolate->heap(); 90 Heap* heap = isolate->heap();
91 91
92 // We need to create several instances to get past the slack-tracking
93 // phase, where mementos aren't emitted.
92 int call_count = 10; 94 int call_count = 10;
95 CHECK_GE(call_count, SharedFunctionInfo::kGenerousAllocationCount);
93 i::ScopedVector<char> test_buf(1024); 96 i::ScopedVector<char> test_buf(1024);
94 const char* program = 97 const char* program =
95 "function f() {" 98 "function f() {"
96 " this.a = 3;" 99 " this.a = 3;"
97 " this.b = {};" 100 " this.b = {};"
98 " return this;" 101 " return this;"
99 "};" 102 "};"
100 "var a;" 103 "var a;"
101 "for(var i = 0; i < %d; i++) {" 104 "for(var i = 0; i < %d; i++) {"
102 " a = new f();" 105 " a = new f();"
103 "}" 106 "}"
104 "a;"; 107 "a;";
105 i::OS::SNPrintF(test_buf, program, call_count); 108 i::OS::SNPrintF(test_buf, program, call_count);
106 v8::Local<v8::Value> res = CompileRun(test_buf.start()); 109 v8::Local<v8::Value> res = CompileRun(test_buf.start());
107 Handle<JSObject> o = 110 Handle<JSObject> o =
108 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); 111 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
109 112
110 // The object of class f should have a memento secreted behind it. 113 // The object of class f should have a memento secreted behind it.
111 Address memento_address = o->address() + o->map()->instance_size(); 114 Address memento_address = o->address() + o->map()->instance_size();
112 AllocationMemento* memento = 115 AllocationMemento* memento =
113 reinterpret_cast<AllocationMemento*>(memento_address + kHeapObjectTag); 116 reinterpret_cast<AllocationMemento*>(memento_address + kHeapObjectTag);
114 CHECK_EQ(memento->map(), heap->allocation_memento_map()); 117 CHECK_EQ(memento->map(), heap->allocation_memento_map());
115 118
116 // Furthermore, how many mementos did we create? The count should match 119 // Furthermore, how many mementos did we create? The count should match
117 // call_count. Note, that mementos are allocated during the inobject slack 120 // call_count - SharedFunctionInfo::kGenerousAllocationCount.
118 // tracking phase.
119 AllocationSite* site = memento->GetAllocationSite(); 121 AllocationSite* site = memento->GetAllocationSite();
120 CHECK_EQ(call_count, site->pretenure_create_count()->value()); 122 CHECK_EQ(call_count - SharedFunctionInfo::kGenerousAllocationCount,
123 site->pretenure_create_count()->value());
121 } 124 }
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698