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

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

Issue 23699002: load ics for js api accessors (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: as discussed Created 7 years, 3 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
« src/ic.cc ('K') | « src/x64/stub-cache-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 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 obj->SetAccessorProperty(v8_str("x1"), 198 obj->SetAccessorProperty(v8_str("x1"),
199 v8::FunctionTemplate::New(XGetter), 199 v8::FunctionTemplate::New(XGetter),
200 v8::FunctionTemplate::New(XSetter)); 200 v8::FunctionTemplate::New(XSetter));
201 x_holder = obj->NewInstance(); 201 x_holder = obj->NewInstance();
202 context->Global()->Set(v8_str("holder"), x_holder); 202 context->Global()->Set(v8_str("holder"), x_holder);
203 x_receiver = v8::Object::New(); 203 x_receiver = v8::Object::New();
204 context->Global()->Set(v8_str("obj"), x_receiver); 204 context->Global()->Set(v8_str("obj"), x_receiver);
205 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(CompileRun( 205 v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(CompileRun(
206 "obj.__proto__ = holder;" 206 "obj.__proto__ = holder;"
207 "var result = [];" 207 "var result = [];"
208 "var key_0 = 'x0';"
209 "var key_1 = 'x1';"
208 "for (var i = 0; i < 10; i++) {" 210 "for (var i = 0; i < 10; i++) {"
209 " holder.x0 = i;" 211 " holder.x0 = i;"
212 " result.push(obj.x0);"
210 " holder.x1 = i;" 213 " holder.x1 = i;"
211 " result.push(obj.x0);"
212 " result.push(obj.x1);" 214 " result.push(obj.x1);"
215 " holder[key_0] = i;"
216 " result.push(obj[key_0]);"
217 " holder[key_1] = i;"
218 " result.push(obj[key_1]);"
213 "}" 219 "}"
214 "result")); 220 "result"));
215 CHECK_EQ(20, array->Length()); 221 CHECK_EQ(40, array->Length());
216 for (int i = 0; i < 20; i++) { 222 for (int i = 0; i < 40; i++) {
217 v8::Handle<Value> entry = array->Get(v8::Integer::New(i)); 223 v8::Handle<Value> entry = array->Get(v8::Integer::New(i));
218 CHECK_EQ(v8::Integer::New(i/2), entry); 224 CHECK_EQ(v8::Integer::New(i/4), entry);
219 } 225 }
220 } 226 }
221 227
222 228
223 static void AccessorProhibitsOverwritingGetter( 229 static void AccessorProhibitsOverwritingGetter(
224 Local<String> name, 230 Local<String> name,
225 const v8::PropertyCallbackInfo<v8::Value>& info) { 231 const v8::PropertyCallbackInfo<v8::Value>& info) {
226 ApiTestFuzzer::Fuzz(); 232 ApiTestFuzzer::Fuzz();
227 info.GetReturnValue().Set(true); 233 info.GetReturnValue().Set(true);
228 } 234 }
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 LocalContext env; 544 LocalContext env;
539 v8::HandleScope scope(env->GetIsolate()); 545 v8::HandleScope scope(env->GetIsolate());
540 546
541 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); 547 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
542 obj->SetNamedPropertyHandler( 548 obj->SetNamedPropertyHandler(
543 JSONStringifyGetter, NULL, NULL, NULL, JSONStringifyEnumerator); 549 JSONStringifyGetter, NULL, NULL, NULL, JSONStringifyEnumerator);
544 env->Global()->Set(v8_str("obj"), obj->NewInstance()); 550 env->Global()->Set(v8_str("obj"), obj->NewInstance());
545 v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}"); 551 v8::Handle<v8::String> expected = v8_str("{\"regress\":\"crbug-161028\"}");
546 CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected)); 552 CHECK(CompileRun("JSON.stringify(obj)")->Equals(expected));
547 } 553 }
OLDNEW
« src/ic.cc ('K') | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698