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

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

Issue 24071002: 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
« no previous file with comments | « 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
20494 #endif // V8_OS_POSIX 20495 #endif // V8_OS_POSIX
20496
20497
20498 static Local<Value> function_new_expected_env;
20499 static void FunctionNewCallback(const v8::FunctionCallbackInfo<Value>& info) {
20500 CHECK_EQ(function_new_expected_env, info.Data());
20501 info.GetReturnValue().Set(17);
20502 }
20503
20504
20505 THREADED_TEST(FunctionNew) {
20506 LocalContext env;
20507 v8::Isolate* isolate = env->GetIsolate();
20508 v8::HandleScope scope(isolate);
20509 Local<Object> data = v8::Object::New();
20510 function_new_expected_env = data;
20511 Local<Function> func = Function::New(isolate, FunctionNewCallback, data);
20512 env->Global()->Set(v8_str("func"), func);
20513 Local<Value> result = CompileRun("func();");
20514 CHECK_EQ(v8::Integer::New(17, isolate), result);
20515 // Verify function not cached
20516 int serial_number =
20517 i::Smi::cast(v8::Utils::OpenHandle(*func)
20518 ->shared()->get_api_func_data()->serial_number())->value();
20519 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
20520 i::Object* elm = i_isolate->native_context()->function_cache()
20521 ->GetElementNoExceptionThrown(i_isolate, serial_number);
20522 CHECK(elm->IsNull());
20523 }
20524
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698