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

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

Issue 258243003: Remove old-style accessor support from runtime. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comment 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/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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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 "v8.h" 28 #include "v8.h"
29 #include "accessors.h" 29 #include "accessors.h"
30 #include "api.h"
30 31
31 #include "cctest.h" 32 #include "cctest.h"
32 33
33 34
34 using namespace v8::internal; 35 using namespace v8::internal;
35 36
36 37
37 static MaybeObject* AllocateAfterFailures() { 38 static MaybeObject* AllocateAfterFailures() {
38 static int attempts = 0; 39 static int attempts = 0;
39 if (++attempts < 3) return Failure::RetryAfterGC(); 40 if (++attempts < 3) return Failure::RetryAfterGC();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 TEST(StressHandles) { 98 TEST(StressHandles) {
98 v8::HandleScope scope(CcTest::isolate()); 99 v8::HandleScope scope(CcTest::isolate());
99 v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate()); 100 v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate());
100 env->Enter(); 101 env->Enter();
101 Handle<Object> o = Test(); 102 Handle<Object> o = Test();
102 CHECK(o->IsSmi() && Smi::cast(*o)->value() == 42); 103 CHECK(o->IsSmi() && Smi::cast(*o)->value() == 42);
103 env->Exit(); 104 env->Exit();
104 } 105 }
105 106
106 107
107 static Object* TestAccessorGet(Isolate* isolate, Object* object, void*) { 108 void TestGetter(
108 return *Test(); 109 v8::Local<v8::String> name,
110 const v8::PropertyCallbackInfo<v8::Value>& info) {
111 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
112 HandleScope scope(isolate);
113 info.GetReturnValue().Set(v8::Utils::ToLocal(Test()));
109 } 114 }
110 115
111 116
112 const AccessorDescriptor kDescriptor = { 117 void TestSetter(
113 TestAccessorGet, 118 v8::Local<v8::String> name,
114 0, 119 v8::Local<v8::Value> value,
115 0 120 const v8::PropertyCallbackInfo<void>& info) {
116 }; 121 UNREACHABLE();
122 }
123
124
125 Handle<AccessorInfo> TestAccessorInfo(
126 Isolate* isolate, PropertyAttributes attributes) {
127 Handle<String> name = isolate->factory()->NewStringFromStaticAscii("get");
128 return Accessors::MakeAccessor(isolate, name, &TestGetter, &TestSetter,
129 attributes);
130 }
117 131
118 132
119 TEST(StressJS) { 133 TEST(StressJS) {
120 Isolate* isolate = CcTest::i_isolate(); 134 Isolate* isolate = CcTest::i_isolate();
121 Factory* factory = isolate->factory(); 135 Factory* factory = isolate->factory();
122 v8::HandleScope scope(CcTest::isolate()); 136 v8::HandleScope scope(CcTest::isolate());
123 v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate()); 137 v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate());
124 env->Enter(); 138 env->Enter();
125 Handle<JSFunction> function = factory->NewFunctionWithPrototype( 139 Handle<JSFunction> function = factory->NewFunctionWithPrototype(
126 factory->function_string(), factory->null_value()); 140 factory->function_string(), factory->null_value());
127 // Force the creation of an initial map and set the code to 141 // Force the creation of an initial map and set the code to
128 // something empty. 142 // something empty.
129 factory->NewJSObject(function); 143 factory->NewJSObject(function);
130 function->ReplaceCode(CcTest::i_isolate()->builtins()->builtin( 144 function->ReplaceCode(CcTest::i_isolate()->builtins()->builtin(
131 Builtins::kEmptyFunction)); 145 Builtins::kEmptyFunction));
132 // Patch the map to have an accessor for "get". 146 // Patch the map to have an accessor for "get".
133 Handle<Map> map(function->initial_map()); 147 Handle<Map> map(function->initial_map());
134 Handle<DescriptorArray> instance_descriptors(map->instance_descriptors()); 148 Handle<DescriptorArray> instance_descriptors(map->instance_descriptors());
135 Handle<Foreign> foreign = factory->NewForeign(&kDescriptor);
136 Handle<String> name = factory->NewStringFromStaticAscii("get");
137 ASSERT(instance_descriptors->IsEmpty()); 149 ASSERT(instance_descriptors->IsEmpty());
138 150
151 PropertyAttributes attrs = static_cast<PropertyAttributes>(0);
152 Handle<AccessorInfo> foreign = TestAccessorInfo(isolate, attrs);
139 Map::EnsureDescriptorSlack(map, 1); 153 Map::EnsureDescriptorSlack(map, 1);
140 154
141 CallbacksDescriptor d(name, 155 CallbacksDescriptor d(Handle<Name>(Name::cast(foreign->name())),
142 foreign, 156 foreign, attrs);
143 static_cast<PropertyAttributes>(0));
144 map->AppendDescriptor(&d); 157 map->AppendDescriptor(&d);
145 158
146 // Add the Foo constructor the global object. 159 // Add the Foo constructor the global object.
147 env->Global()->Set(v8::String::NewFromUtf8(CcTest::isolate(), "Foo"), 160 env->Global()->Set(v8::String::NewFromUtf8(CcTest::isolate(), "Foo"),
148 v8::Utils::ToLocal(function)); 161 v8::Utils::ToLocal(function));
149 // Call the accessor through JavaScript. 162 // Call the accessor through JavaScript.
150 v8::Handle<v8::Value> result = v8::Script::Compile( 163 v8::Handle<v8::Value> result = v8::Script::Compile(
151 v8::String::NewFromUtf8(CcTest::isolate(), "(new Foo).get"))->Run(); 164 v8::String::NewFromUtf8(CcTest::isolate(), "(new Foo).get"))->Run();
152 CHECK_EQ(42, result->Int32Value()); 165 CHECK_EQ(42, result->Int32Value());
153 env->Exit(); 166 env->Exit();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 if (index < blocks.length() - 1) { 229 if (index < blocks.length() - 1) {
217 blocks[index] = blocks.RemoveLast(); 230 blocks[index] = blocks.RemoveLast();
218 } else { 231 } else {
219 blocks.RemoveLast(); 232 blocks.RemoveLast();
220 } 233 }
221 } 234 }
222 } 235 }
223 236
224 code_range.TearDown(); 237 code_range.TearDown();
225 } 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