| 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 20317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20328 THREADED_TEST(FunctionNew) { | 20328 THREADED_TEST(FunctionNew) { |
| 20329 LocalContext env; | 20329 LocalContext env; |
| 20330 v8::Isolate* isolate = env->GetIsolate(); | 20330 v8::Isolate* isolate = env->GetIsolate(); |
| 20331 v8::HandleScope scope(isolate); | 20331 v8::HandleScope scope(isolate); |
| 20332 Local<Object> data = v8::Object::New(isolate); | 20332 Local<Object> data = v8::Object::New(isolate); |
| 20333 function_new_expected_env = data; | 20333 function_new_expected_env = data; |
| 20334 Local<Function> func = Function::New(isolate, FunctionNewCallback, data); | 20334 Local<Function> func = Function::New(isolate, FunctionNewCallback, data); |
| 20335 env->Global()->Set(v8_str("func"), func); | 20335 env->Global()->Set(v8_str("func"), func); |
| 20336 Local<Value> result = CompileRun("func();"); | 20336 Local<Value> result = CompileRun("func();"); |
| 20337 CHECK(v8::Integer::New(isolate, 17)->Equals(result)); | 20337 CHECK(v8::Integer::New(isolate, 17)->Equals(result)); |
| 20338 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 20338 // Verify function not cached | 20339 // Verify function not cached |
| 20339 int serial_number = | 20340 auto serial_number = handle(i::Smi::cast(v8::Utils::OpenHandle(*func) |
| 20340 i::Smi::cast(v8::Utils::OpenHandle(*func) | 20341 ->shared() |
| 20341 ->shared()->get_api_func_data()->serial_number())->value(); | 20342 ->get_api_func_data() |
| 20342 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 20343 ->serial_number()), |
| 20343 i::Handle<i::FixedArray> cache(i_isolate->native_context()->function_cache()); | 20344 i_isolate); |
| 20344 if (serial_number < cache->length()) { | 20345 auto cache = i_isolate->function_cache(); |
| 20345 CHECK(cache->get(serial_number)->IsUndefined()); | 20346 CHECK(cache->Lookup(serial_number)->IsTheHole()); |
| 20346 } | |
| 20347 // Verify that each Function::New creates a new function instance | 20347 // Verify that each Function::New creates a new function instance |
| 20348 Local<Object> data2 = v8::Object::New(isolate); | 20348 Local<Object> data2 = v8::Object::New(isolate); |
| 20349 function_new_expected_env = data2; | 20349 function_new_expected_env = data2; |
| 20350 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); | 20350 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); |
| 20351 CHECK(!func2->IsNull()); | 20351 CHECK(!func2->IsNull()); |
| 20352 CHECK(!func->Equals(func2)); | 20352 CHECK(!func->Equals(func2)); |
| 20353 env->Global()->Set(v8_str("func2"), func2); | 20353 env->Global()->Set(v8_str("func2"), func2); |
| 20354 Local<Value> result2 = CompileRun("func2();"); | 20354 Local<Value> result2 = CompileRun("func2();"); |
| 20355 CHECK(v8::Integer::New(isolate, 17)->Equals(result2)); | 20355 CHECK(v8::Integer::New(isolate, 17)->Equals(result2)); |
| 20356 } | 20356 } |
| (...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21939 } | 21939 } |
| 21940 { | 21940 { |
| 21941 v8::TryCatch try_catch; | 21941 v8::TryCatch try_catch; |
| 21942 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); | 21942 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); |
| 21943 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, | 21943 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, |
| 21944 length).IsEmpty()); | 21944 length).IsEmpty()); |
| 21945 CHECK(try_catch.HasCaught()); | 21945 CHECK(try_catch.HasCaught()); |
| 21946 } | 21946 } |
| 21947 free(buffer); | 21947 free(buffer); |
| 21948 } | 21948 } |
| OLD | NEW |