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

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

Issue 23561007: add uncached Function::New (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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/apinatives.js ('K') | « src/objects-inl.h ('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 20473 matching lines...) Expand 10 before | Expand all | Expand 10 after
20484 "function setAge(i) { obj.age = i };" 20484 "function setAge(i) { obj.age = i };"
20485 "setAge(100);" 20485 "setAge(100);"
20486 "setAge(101);" 20486 "setAge(101);"
20487 "setAge(102);" 20487 "setAge(102);"
20488 "%OptimizeFunctionOnNextCall(setAge);" 20488 "%OptimizeFunctionOnNextCall(setAge);"
20489 "setAge(103);"); 20489 "setAge(103);");
20490 ExpectInt32("obj.age", 100000); 20490 ExpectInt32("obj.age", 100000);
20491 ExpectInt32("obj.interceptor_age", 103); 20491 ExpectInt32("obj.interceptor_age", 103);
20492 } 20492 }
20493 20493
20494
20495 static Local<Value> function_new_expected_env;
20496 static void FunctionNewCallback(const v8::FunctionCallbackInfo<Value>& info) {
20497 CHECK_EQ(function_new_expected_env, info.Data());
20498 info.GetReturnValue().Set(17);
20499 }
20500
20501
20502 THREADED_TEST(FunctionNew) {
20503 LocalContext env;
20504 v8::Isolate* isolate = env->GetIsolate();
20505 v8::HandleScope scope(isolate);
20506 Local<Object> data = v8::Object::New();
20507 function_new_expected_env = data;
20508 Local<Function> func = Function::New(isolate, FunctionNewCallback, data);
20509 env->Global()->Set(v8_str("func"), func);
20510 Local<Value> result = CompileRun("func();");
20511 CHECK_EQ(v8::Integer::New(17, isolate), result);
20512 // Verify function not cached
20513 int serial_number =
20514 i::Smi::cast(v8::Utils::OpenHandle(*func)
20515 ->shared()->get_api_func_data()->serial_number())->value();
20516 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
20517 i::Object* elm = i_isolate->native_context()->function_cache()
20518 ->GetElementNoExceptionThrown(i_isolate, serial_number);
20519 CHECK(elm->IsNull());
20520 }
20521
20522
20494 #endif // V8_OS_POSIX 20523 #endif // V8_OS_POSIX
Michael Starzinger 2013/09/06 14:41:50 I think this #endif was already misplaced before.
dcarney 2013/09/06 17:59:49 when i see a 20,000 line file, I just stick new co
OLDNEW
« src/apinatives.js ('K') | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698