OLD | NEW |
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 20020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20031 THREADED_TEST(FunctionNew) { | 20031 THREADED_TEST(FunctionNew) { |
20032 LocalContext env; | 20032 LocalContext env; |
20033 v8::Isolate* isolate = env->GetIsolate(); | 20033 v8::Isolate* isolate = env->GetIsolate(); |
20034 v8::HandleScope scope(isolate); | 20034 v8::HandleScope scope(isolate); |
20035 Local<Object> data = v8::Object::New(isolate); | 20035 Local<Object> data = v8::Object::New(isolate); |
20036 function_new_expected_env = data; | 20036 function_new_expected_env = data; |
20037 Local<Function> func = Function::New(isolate, FunctionNewCallback, data); | 20037 Local<Function> func = Function::New(isolate, FunctionNewCallback, data); |
20038 env->Global()->Set(v8_str("func"), func); | 20038 env->Global()->Set(v8_str("func"), func); |
20039 Local<Value> result = CompileRun("func();"); | 20039 Local<Value> result = CompileRun("func();"); |
20040 CHECK(v8::Integer::New(isolate, 17)->Equals(result)); | 20040 CHECK(v8::Integer::New(isolate, 17)->Equals(result)); |
| 20041 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
20041 // Verify function not cached | 20042 // Verify function not cached |
20042 int serial_number = | 20043 auto serial_number = handle(i::Smi::cast(v8::Utils::OpenHandle(*func) |
20043 i::Smi::cast(v8::Utils::OpenHandle(*func) | 20044 ->shared() |
20044 ->shared()->get_api_func_data()->serial_number())->value(); | 20045 ->get_api_func_data() |
20045 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 20046 ->serial_number()), |
20046 i::Handle<i::FixedArray> cache(i_isolate->native_context()->function_cache()); | 20047 i_isolate); |
20047 if (serial_number < cache->length()) { | 20048 auto cache = i_isolate->function_cache(); |
20048 CHECK(cache->get(serial_number)->IsUndefined()); | 20049 CHECK(cache->Lookup(serial_number)->IsTheHole()); |
20049 } | |
20050 // Verify that each Function::New creates a new function instance | 20050 // Verify that each Function::New creates a new function instance |
20051 Local<Object> data2 = v8::Object::New(isolate); | 20051 Local<Object> data2 = v8::Object::New(isolate); |
20052 function_new_expected_env = data2; | 20052 function_new_expected_env = data2; |
20053 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); | 20053 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); |
20054 CHECK(!func2->IsNull()); | 20054 CHECK(!func2->IsNull()); |
20055 CHECK(!func->Equals(func2)); | 20055 CHECK(!func->Equals(func2)); |
20056 env->Global()->Set(v8_str("func2"), func2); | 20056 env->Global()->Set(v8_str("func2"), func2); |
20057 Local<Value> result2 = CompileRun("func2();"); | 20057 Local<Value> result2 = CompileRun("func2();"); |
20058 CHECK(v8::Integer::New(isolate, 17)->Equals(result2)); | 20058 CHECK(v8::Integer::New(isolate, 17)->Equals(result2)); |
20059 } | 20059 } |
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21638 } | 21638 } |
21639 { | 21639 { |
21640 v8::TryCatch try_catch; | 21640 v8::TryCatch try_catch; |
21641 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); | 21641 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); |
21642 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, | 21642 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, |
21643 length).IsEmpty()); | 21643 length).IsEmpty()); |
21644 CHECK(try_catch.HasCaught()); | 21644 CHECK(try_catch.HasCaught()); |
21645 } | 21645 } |
21646 free(buffer); | 21646 free(buffer); |
21647 } | 21647 } |
OLD | NEW |