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 21991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22002 function_new_expected_env = data; | 22002 function_new_expected_env = data; |
22003 Local<Function> func = Function::New(isolate, FunctionNewCallback, data); | 22003 Local<Function> func = Function::New(isolate, FunctionNewCallback, data); |
22004 env->Global()->Set(v8_str("func"), func); | 22004 env->Global()->Set(v8_str("func"), func); |
22005 Local<Value> result = CompileRun("func();"); | 22005 Local<Value> result = CompileRun("func();"); |
22006 CHECK_EQ(v8::Integer::New(isolate, 17), result); | 22006 CHECK_EQ(v8::Integer::New(isolate, 17), result); |
22007 // Verify function not cached | 22007 // Verify function not cached |
22008 int serial_number = | 22008 int serial_number = |
22009 i::Smi::cast(v8::Utils::OpenHandle(*func) | 22009 i::Smi::cast(v8::Utils::OpenHandle(*func) |
22010 ->shared()->get_api_func_data()->serial_number())->value(); | 22010 ->shared()->get_api_func_data()->serial_number())->value(); |
22011 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 22011 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
22012 i::Object* elm = i_isolate->native_context()->function_cache() | 22012 i::Handle<i::JSObject> cache(i_isolate->native_context()->function_cache()); |
22013 ->GetElementNoExceptionThrown(i_isolate, serial_number); | 22013 i::Handle<i::Object> elm = |
| 22014 i::Object::GetElementNoExceptionThrown(i_isolate, cache, serial_number); |
22014 CHECK(elm->IsUndefined()); | 22015 CHECK(elm->IsUndefined()); |
22015 // Verify that each Function::New creates a new function instance | 22016 // Verify that each Function::New creates a new function instance |
22016 Local<Object> data2 = v8::Object::New(isolate); | 22017 Local<Object> data2 = v8::Object::New(isolate); |
22017 function_new_expected_env = data2; | 22018 function_new_expected_env = data2; |
22018 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); | 22019 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); |
22019 CHECK(!func2->IsNull()); | 22020 CHECK(!func2->IsNull()); |
22020 CHECK_NE(func, func2); | 22021 CHECK_NE(func, func2); |
22021 env->Global()->Set(v8_str("func2"), func2); | 22022 env->Global()->Set(v8_str("func2"), func2); |
22022 Local<Value> result2 = CompileRun("func2();"); | 22023 Local<Value> result2 = CompileRun("func2();"); |
22023 CHECK_EQ(v8::Integer::New(isolate, 17), result2); | 22024 CHECK_EQ(v8::Integer::New(isolate, 17), result2); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22420 TEST(ThrowOnJavascriptExecution) { | 22421 TEST(ThrowOnJavascriptExecution) { |
22421 LocalContext context; | 22422 LocalContext context; |
22422 v8::Isolate* isolate = context->GetIsolate(); | 22423 v8::Isolate* isolate = context->GetIsolate(); |
22423 v8::HandleScope scope(isolate); | 22424 v8::HandleScope scope(isolate); |
22424 v8::TryCatch try_catch; | 22425 v8::TryCatch try_catch; |
22425 v8::Isolate::DisallowJavascriptExecutionScope throw_js( | 22426 v8::Isolate::DisallowJavascriptExecutionScope throw_js( |
22426 isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); | 22427 isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); |
22427 CompileRun("1+1"); | 22428 CompileRun("1+1"); |
22428 CHECK(try_catch.HasCaught()); | 22429 CHECK(try_catch.HasCaught()); |
22429 } | 22430 } |
OLD | NEW |