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

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

Issue 699473002: 429168: fix for PdfJs regression (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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/serialize.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 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 int instance_size = JSObject::kHeaderSize; 79 int instance_size = JSObject::kHeaderSize;
80 heap->AllocateMap(JS_OBJECT_TYPE, instance_size).ToObjectChecked(); 80 heap->AllocateMap(JS_OBJECT_TYPE, instance_size).ToObjectChecked();
81 81
82 // Test that we can allocate in old pointer space and code space. 82 // Test that we can allocate in old pointer space and code space.
83 SimulateFullSpace(heap->code_space()); 83 SimulateFullSpace(heap->code_space());
84 heap->AllocateFixedArray(100, TENURED).ToObjectChecked(); 84 heap->AllocateFixedArray(100, TENURED).ToObjectChecked();
85 heap->CopyCode(CcTest::i_isolate()->builtins()->builtin( 85 heap->CopyCode(CcTest::i_isolate()->builtins()->builtin(
86 Builtins::kIllegal)).ToObjectChecked(); 86 Builtins::kIllegal)).ToObjectChecked();
87 87
88 // Return success. 88 // Return success.
89 return Smi::FromInt(42); 89 return heap->true_value();
90 } 90 }
91 91
92 92
93 static Handle<Object> Test() { 93 static Handle<Object> Test() {
94 CALL_HEAP_FUNCTION(CcTest::i_isolate(), AllocateAfterFailures(), Object); 94 CALL_HEAP_FUNCTION(CcTest::i_isolate(), AllocateAfterFailures(), Object);
95 } 95 }
96 96
97 97
98 TEST(StressHandles) { 98 TEST(StressHandles) {
99 v8::HandleScope scope(CcTest::isolate()); 99 v8::HandleScope scope(CcTest::isolate());
100 v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate()); 100 v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate());
101 env->Enter(); 101 env->Enter();
102 Handle<Object> o = Test(); 102 Handle<Object> o = Test();
103 CHECK(o->IsSmi() && Smi::cast(*o)->value() == 42); 103 CHECK(o->IsTrue());
104 env->Exit(); 104 env->Exit();
105 } 105 }
106 106
107 107
108 void TestGetter( 108 void TestGetter(
109 v8::Local<v8::Name> name, 109 v8::Local<v8::Name> name,
110 const v8::PropertyCallbackInfo<v8::Value>& info) { 110 const v8::PropertyCallbackInfo<v8::Value>& info) {
111 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 111 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
112 HandleScope scope(isolate); 112 HandleScope scope(isolate);
113 info.GetReturnValue().Set(v8::Utils::ToLocal(Test())); 113 info.GetReturnValue().Set(v8::Utils::ToLocal(Test()));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 CallbacksDescriptor d(Handle<Name>(Name::cast(foreign->name())), 155 CallbacksDescriptor d(Handle<Name>(Name::cast(foreign->name())),
156 foreign, attrs); 156 foreign, attrs);
157 map->AppendDescriptor(&d); 157 map->AppendDescriptor(&d);
158 158
159 // Add the Foo constructor the global object. 159 // Add the Foo constructor the global object.
160 env->Global()->Set(v8::String::NewFromUtf8(CcTest::isolate(), "Foo"), 160 env->Global()->Set(v8::String::NewFromUtf8(CcTest::isolate(), "Foo"),
161 v8::Utils::ToLocal(function)); 161 v8::Utils::ToLocal(function));
162 // Call the accessor through JavaScript. 162 // Call the accessor through JavaScript.
163 v8::Handle<v8::Value> result = v8::Script::Compile( 163 v8::Handle<v8::Value> result = v8::Script::Compile(
164 v8::String::NewFromUtf8(CcTest::isolate(), "(new Foo).get"))->Run(); 164 v8::String::NewFromUtf8(CcTest::isolate(), "(new Foo).get"))->Run();
165 CHECK_EQ(42, result->Int32Value()); 165 CHECK_EQ(true, result->BooleanValue());
166 env->Exit(); 166 env->Exit();
167 } 167 }
168 168
169 169
170 // CodeRange test. 170 // CodeRange test.
171 // Tests memory management in a CodeRange by allocating and freeing blocks, 171 // Tests memory management in a CodeRange by allocating and freeing blocks,
172 // using a pseudorandom generator to choose block sizes geometrically 172 // using a pseudorandom generator to choose block sizes geometrically
173 // distributed between 2 * Page::kPageSize and 2^5 + 1 * Page::kPageSize. 173 // distributed between 2 * Page::kPageSize and 2^5 + 1 * Page::kPageSize.
174 // Ensure that the freed chunks are collected and reused by allocating (in 174 // Ensure that the freed chunks are collected and reused by allocating (in
175 // total) more than the size of the CodeRange. 175 // total) more than the size of the CodeRange.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if (index < blocks.length() - 1) { 229 if (index < blocks.length() - 1) {
230 blocks[index] = blocks.RemoveLast(); 230 blocks[index] = blocks.RemoveLast();
231 } else { 231 } else {
232 blocks.RemoveLast(); 232 blocks.RemoveLast();
233 } 233 }
234 } 234 }
235 } 235 }
236 236
237 code_range.TearDown(); 237 code_range.TearDown();
238 } 238 }
OLDNEW
« no previous file with comments | « src/serialize.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698