Home | History | Annotate | Download | only in cctest

Lines Matching refs:v8

1 // Copyright 2012 the V8 project authors. All rights reserved.
30 #include "v8.h"
53 using ::v8::AccessorInfo;
54 using ::v8::Arguments;
55 using ::v8::Context;
56 using ::v8::Extension;
57 using ::v8::Function;
58 using ::v8::FunctionTemplate;
59 using ::v8::Handle;
60 using ::v8::HandleScope;
61 using ::v8::Local;
62 using ::v8::Message;
63 using ::v8::MessageCallback;
64 using ::v8::Object;
65 using ::v8::ObjectTemplate;
66 using ::v8::Persistent;
67 using ::v8::Script;
68 using ::v8::StackTrace;
69 using ::v8::String;
70 using ::v8::TryCatch;
71 using ::v8::Undefined;
72 using ::v8::V8;
73 using ::v8::Value;
119 static v8::Handle<Value> IncrementingSignatureCallback(
120 const v8::Arguments& args) {
123 v8::Handle<v8::Array> result = v8::Array::New(args.Length());
125 result->Set(v8::Integer::New(i), args[i]);
130 static v8::Handle<Value> SignatureCallback(const v8::Arguments& args) {
132 v8::Handle<v8::Array> result = v8::Array::New(args.Length());
134 result->Set(v8::Integer::New(i), args[i]);
141 v8::HandleScope scope;
152 v8::Handle<v8::Primitive> undef = v8::Undefined();
166 v8::HandleScope scope;
168 v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New();
169 v8::Handle<v8::Signature> sig = v8::Signature::New(fun);
172 v8::FunctionTemplate::New(IncrementingSignatureCallback,
173 v8::Handle<Value>(),
181 v8::Handle<v8::FunctionTemplate> sub_fun = v8::FunctionTemplate::New();
189 v8::TryCatch try_catch;
197 v8::Handle<v8::FunctionTemplate> unrel_fun = v8::FunctionTemplate::New();
210 v8::HandleScope scope;
212 v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New();
214 v8::Handle<v8::Signature> sig =
215 v8::Signature::New(v8::Handle<v8::FunctionTemplate>(), 1, &cons);
216 v8::Handle<v8::FunctionTemplate> fun =
217 v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), sig);
221 v8::Handle<Value> value1 = CompileRun("Fun1(4) == '';");
224 v8::Handle<Value> value2 = CompileRun("Fun1(new Cons()) == '[object Cons]';");
227 v8::Handle<Value> value3 = CompileRun("Fun1() == '';");
230 v8::Handle<v8::FunctionTemplate> cons1 = v8::FunctionTemplate::New();
232 v8::Handle<v8::FunctionTemplate> cons2 = v8::FunctionTemplate::New();
234 v8::Handle<v8::FunctionTemplate> cons3 = v8::FunctionTemplate::New();
237 v8::Handle<v8::FunctionTemplate> args[3] = { cons1, cons2, cons3 };
238 v8::Handle<v8::Signature> wsig =
239 v8::Signature::New(v8::Handle<v8::FunctionTemplate>(), 3, args);
240 v8::Handle<v8::FunctionTemplate> fun2 =
241 v8::FunctionTemplate::New(SignatureCallback, v8::Handle<Value>(), wsig);
247 v8::Handle<Value> value4 = CompileRun(
252 v8::Handle<Value> value5 = CompileRun(
256 v8::Handle<Value> value6 = CompileRun(
260 v8::Handle<Value> value7 = CompileRun(
265 v8::Handle<Value> value8 = CompileRun(
272 v8::HandleScope scope;
274 v8::Handle<v8::Primitive> undef = v8::Undefined();
284 v8::HandleScope scope;
286 Local<v8::Object> obj = v8::Object::New();
299 v8::HandleScope scope;
301 Local<v8::Object> obj = v8::Object::New();
311 Local<v8::Array> value = CompileRun("[\"a\", \"b\"]").As<v8::Array>();
318 v8::HandleScope scope;
390 v8::HandleScope scope;
404 v8::internal::Isolate::Current()->compilation_cache()->Clear();
414 v8::HandleScope scope;
436 v8::HandleScope scope;
462 v8::HandleScope scope;
485 v8::HandleScope scope;
531 v8::HandleScope scope;
569 v8::HandleScope scope;
573 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
587 v8::HandleScope scope;
591 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
607 v8::HandleScope scope;
612 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
627 v8::HandleScope scope;
631 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
673 v8::HandleScope scope;
694 v8::HandleScope scope;
713 v8::HandleScope scope;
758 v8::HandleScope scope;
760 v8::Handle<v8::Object> global = env->Global();
767 static v8::Handle<Value> handle_call(const v8::Arguments& args) {
773 static v8::Handle<Value> construct_call(const v8::Arguments& args) {
780 static v8::Handle<Value> Return239(Local<String> name, const AccessorInfo&) {
787 v8::HandleScope scope;
790 Local<v8::FunctionTemplate> fun_templ =
791 v8::FunctionTemplate::New(handle_call);
800 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
809 Local<v8::FunctionTemplate> fun_templ =
810 v8::FunctionTemplate::New(construct_call);
828 static v8::Handle<v8::Value> callback(const v8::Arguments& args) {
829 void* ptr = v8::External::Unwrap(args.Data());
831 return v8::True();
836 v8::HandleScope scope;
839 v8::Handle<v8::Value> data = v8::External::Wrap(expected_ptr);
841 v8::Handle<v8::Object> obj = v8::Object::New();
843 v8::FunctionTemplate::New(callback, data)->GetFunction());
901 v8::HandleScope scope;
904 Local<v8::FunctionTemplate> base = v8::FunctionTemplate::New();
905 Local<v8::FunctionTemplate> derived = v8::FunctionTemplate::New();
906 Local<v8::FunctionTemplate> other = v8::FunctionTemplate::New();
909 Local<v8::Function> base_function = base->GetFunction();
910 Local<v8::Function> derived_function = derived->GetFunction();
911 Local<v8::Function> other_function = other->GetFunction();
913 Local<v8::Object> base_instance = base_function->NewInstance();
914 Local<v8::Object> derived_instance = derived_function->NewInstance();
915 Local<v8::Object> derived_instance2 = derived_function->NewInstance();
916 Local<v8::Object> other_instance = other_function->NewInstance();
948 v8::HandleScope scope;
951 Local<v8::Integer> value_obj = v8::Integer::New(value);
957 v8::HandleScope scope;
964 Local<v8::Integer> value_obj = v8::Integer::New(value);
971 v8::HandleScope scope;
981 Local<v8::Integer> value_obj = v8::Integer::New(value);
988 v8::HandleScope scope;
991 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value);
997 v8::HandleScope scope;
1002 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value);
1008 v8::HandleScope scope;
1013 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value);
1019 v8::HandleScope scope;
1024 Local<v8::Integer> value_obj = v8::Integer::NewFromUnsigned(value);
1030 v8::HandleScope scope;
1032 v8::Handle<Value> syntax_error = CompileRun(
1035 v8::Handle<Value> not_error = CompileRun("{a:42}");
1037 v8::Handle<Value> not_object = CompileRun("42");
1043 v8::HandleScope scope;
1045 v8::Handle<Value> boxed_string = CompileRun("new String(\"test\")");
1047 v8::Handle<Value> unboxed_string = CompileRun("\"test\"");
1049 v8::Handle<Value> boxed_not_string = CompileRun("new Number(42)");
1051 v8::Handle<Value> not_object = CompileRun("0");
1053 v8::Handle<v8::StringObject> as_boxed = boxed_string.As<v8::StringObject>();
1055 Local<v8::String> the_string = as_boxed->StringValue();
1058 v8::Handle<v8::Value> new_boxed_string = v8::StringObject::New(the_string);
1060 as_boxed = new_boxed_string.As<v8::StringObject>();
1068 v8::HandleScope scope;
1070 v8::Handle<Value> boxed_number = CompileRun("new Number(42)");
1072 v8::Handle<Value> unboxed_number = CompileRun("42");
1074 v8::Handle<Value> boxed_not_number = CompileRun("new Boolean(false)");
1076 v8::Handle<v8::NumberObject> as_boxed = boxed_number.As<v8::NumberObject>();
1080 v8::Handle<v8::Value> new_boxed_number = v8::NumberObject::New(43);
1082 as_boxed = new_boxed_number.As<v8::NumberObject>();
1089 v8::HandleScope scope;
1091 v8::Handle<Value> boxed_boolean = CompileRun("new Boolean(true)");
1093 v8::Handle<Value> unboxed_boolean = CompileRun("true");
1095 v8::Handle<Value> boxed_not_boolean = CompileRun("new Number(42)");
1097 v8::Handle<v8::BooleanObject> as_boxed =
1098 boxed_boolean.As<v8::BooleanObject>();
1102 v8::Handle<v8::Value> boxed_true = v8::BooleanObject::New(true);
1103 v8::Handle<v8::Value> boxed_false = v8::BooleanObject::New(false);
1106 as_boxed = boxed_true.As<v8::BooleanObject>();
1108 as_boxed = boxed_false.As<v8::BooleanObject>();
1114 v8::HandleScope scope;
1117 Local<v8::Number> pi_obj = v8::Number::New(PI);
1123 v8::HandleScope scope;
1127 v8::Handle<v8::Boolean> t = v8::True();
1129 v8::Handle<v8::Boolean> f = v8::False();
1135 v8::HandleScope scope;
1138 Local<Value> date = v8::Date::New(PI);
1140 date.As<v8::Date>()->Set(v8_str("property"), v8::Integer::New(42));
1141 CHECK_EQ(42, date.As<v8::Date>()->Get(v8_str("property"))->Int32Value());
1146 v8::HandleScope scope;
1148 v8::Handle<v8::Boolean> t = v8::True();
1150 v8::Handle<v8::Boolean> f = v8::False();
1152 v8::Handle<v8::Primitive> u = v8::Undefined();
1154 v8::Handle<v8::Primitive> n = v8::Null();
1156 v8::Handle<String> str1 = v8_str("");
1158 v8::Handle<String> str2 = v8_str("x");
1160 CHECK(!v8::Number::New(0)->BooleanValue());
1161 CHECK(v8::Number::New(-1)->BooleanValue());
1162 CHECK(v8::Number::New(1)->BooleanValue());
1163 CHECK(v8::Number::New(42)->BooleanValue());
1168 static v8::Handle<Value> DummyCallHandler(const v8::Arguments& args) {
1174 static v8::Handle<Value> GetM(Local<String> name, const AccessorInfo&) {
1181 v8::HandleScope scope;
1182 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New();
1185 v8::FunctionTemplate::New(DummyCallHandler));
1186 v8::Handle<ObjectTemplate> templ = func_templ->InstanceTemplate();
1190 v8::Handle<Script> script(v8_compile("dummy()"));
1191 v8::Handle<Value> result(script->Run());
1199 v8::HandleScope scope;
1204 Local<v8::Object> instance1 = templ1->NewInstance();
1208 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New();
1213 Local<v8::Object> instance2 = templ2->NewInstance();
1222 static v8::Handle<Value> GetFlabby(const v8::Arguments& args) {
1228 static v8::Handle<Value> GetKnurd(Local<String> property, const AccessorInfo&) {
1235 v8::HandleScope scope;
1236 v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New();
1238 v8::FunctionTemplate::New(GetFlabby));
1243 v8::Handle<v8::FunctionTemplate> base1 = v8::FunctionTemplate::New();
1247 v8::Handle<v8::FunctionTemplate> base2 = v8::FunctionTemplate::New();
1293 static v8::Handle<Value> EchoNamedProperty(Local<String> name,
1354 v8::AccessorGetter getter,
1355 v8::AccessorSetter setter) {
1360 v8::NamedPropertyGetter getter,
1361 v8::NamedPropertySetter setter) {
1366 v8::HandleScope scope;
1383 v8::HandleScope scope;
1403 v8::HandleScope scope;
1422 v8::HandleScope scope;
1439 v8::HandleScope scope;
1456 v8::HandleScope scope;
1475 v8::HandleScope scope;
1494 v8::HandleScope scope;
1518 v8::HandleScope scope;
1542 v8::HandleScope scope;
1559 v8::HandleScope scope;
1577 v8::HandleScope scope;
1578 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
1589 v8::Handle<Value> str = CompileRun(code);
1602 static v8::Handle<Value> EchoIndexedProperty(uint32_t index,
1612 v8::HandleScope scope;
1613 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
1625 v8::Handle<v8::Object> bottom;
1627 static v8::Handle<Value> CheckThisIndexedPropertyHandler(
1632 return v8::Handle<Value>();
1635 static v8::Handle<Value> CheckThisNamedPropertyHandler(
1640 return v8::Handle<Value>();
1644 v8::Handle<Value> CheckThisIndexedPropertySetter(uint32_t index,
1649 return v8::Handle<Value>();
1653 v8::Handle<Value> CheckThisNamedPropertySetter(Local<String> property,
1658 return v8::Handle<Value>();
1661 v8::Handle<v8::Integer> CheckThisIndexedPropertyQuery(
1666 return v8::Handle<v8::Integer>();
1670 v8::Handle<v8::Integer> CheckThisNamedPropertyQuery(Local<String> property,
1674 return v8::Handle<v8::Integer>();
1678 v8::Handle<v8::Boolean> CheckThisIndexedPropertyDeleter(
1683 return v8::Handle<v8::Boolean>();
1687 v8::Handle<v8::Boolean> CheckThisNamedPropertyDeleter(
1692 return v8::Handle<v8::Boolean>();
1696 v8::Handle<v8::Array> CheckThisIndexedPropertyEnumerator(
1700 return v8::Handle<v8::Array>();
1704 v8::Handle<v8::Array> CheckThisNamedPropertyEnumerator(
1708 return v8::Handle<v8::Array>();
1713 v8::HandleScope scope;
1717 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
1733 Local<v8::Object> top = templ->GetFunction()->NewInstance();
1734 Local<v8::Object> middle = templ->GetFunction()->NewInstance();
1761 static v8::Handle<Value> PrePropertyHandlerGet(Local<String> key,
1767 return v8::Handle<String>();
1771 static v8::Handle<v8::Integer> PrePropertyHandlerQuery(Local<String> key,
1774 return v8::Integer::New(v8::None);
1777 return v8::Handle<v8::Integer>(); // do not intercept the call
1782 v8::HandleScope scope;
1783 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New();
1790 v8::Handle<Value> result_pre = Script::Compile(v8_str("pre"))->Run();
1792 v8::Handle<Value> result_on = Script::Compile(v8_str("on"))->Run();
1794 v8::Handle<Value> result_post = Script::Compile(v8_str("post"))->Run();
1800 v8::HandleScope scope;
1802 v8::Handle<Value> result = Script::Compile(v8_str(
1808 v8::Handle<Script> call_recursively_script;
1812 static v8::Handle<Value> CallScriptRecursivelyCall(const v8::Arguments& args) {
1815 if (depth == kTargetRecursionDepth) return v8::Undefined();
1816 args.This()->Set(v8_str("depth"), v8::Integer::New(depth + 1));
1821 static v8::Handle<Value> CallFunctionRecursivelyCall(
1822 const v8::Arguments& args) {
1827 return v8::Undefined();
1829 args.This()->Set(v8_str("depth"), v8::Integer::New(depth + 1));
1830 v8::Handle<Value> function =
1837 v8::HandleScope scope;
1838 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New();
1840 v8::FunctionTemplate::New(CallScriptRecursivelyCall));
1842 v8::FunctionTemplate::New(CallFunctionRecursivelyCall));
1845 env->Global()->Set(v8_str("depth"), v8::Integer::New(0));
1848 call_recursively_script = v8::Handle<Script>();
1850 env->Global()->Set(v8_str("depth"), v8::Integer::New(0));
1855 static v8::Handle<Value>
1858 return v8::ThrowException(key);
1862 static v8::Handle<Value> ThrowingPropertyHandlerSet(Local<String> key,
1865 v8::ThrowException(key);
1866 return v8::Undefined(); // not the same as v8::Handle<v8::Value>()
1871 v8::HandleScope scope;
1872 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
1877 v8::Handle<Value> otto = Script::Compile(v8_str(
1880 v8::Handle<Value> netto = Script::Compile(v8_str(
1887 v8::HandleScope scope;
1888 Local<v8::FunctionTemplate> Foo = v8::FunctionTemplate::New();
1898 v8::HandleScope scope;
1901 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
1902 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
1904 Local<v8
1913 v8::HandleScope scope;
1914 Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
1917 v8::Handle<v8::Object> global_proxy = env->Global();
1918 v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>();
1927 v8::HandleScope scope;
1930 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
1931 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
1933 Local<v8::Object> obj = templ->GetFunction()->NewInstance();
1959 v8::HandleScope scope;
1962 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
1963 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
1965 Local<v8::Object> obj = templ->GetFunction()->NewInstance();
1978 CHECK_EQ(aligned, v8::External::Unwrap(obj->GetInternalField(0)));
1982 CHECK_EQ(unaligned, v8::External::Unwrap(obj->GetInternalField(0)));
1984 obj->SetInternalField(0, v8::External::Wrap(aligned));
1988 obj->SetInternalField(0, v8::External::Wrap(unaligned));
1997 v8::HandleScope scope;
2003 Local<v8::Object> obj = v8::Object::New();
2007 int hash2 = v8::Object::New()->GetIdentityHash();
2013 int hash3 = v8::Object::New()->GetIdentityHash();
2022 // Put a getter for 'v8::IdentityHash' on the Object's prototype:
2024 CompileRun("Object.prototype['v8::IdentityHash'] = 42;\n");
2025 Local<v8::Object> o1 = v8::Object::New();
2026 Local<v8::Object> o2 = v8::Object::New();
2032 "Object.prototype.__defineGetter__('v8::IdentityHash', cnst);\n");
2033 Local<v8::Object> o1 = v8::Object::New();
2034 Local<v8::Object> o2 = v8::Object::New();
2041 v8::HandleScope scope;
2044 v8::Local<v8::Object> obj = v8::Object::New();
2045 v8::Local<v8::String> key = v8_str("api-test::hidden-key");
2046 v8::Local<v8::String> empty = v8_str("");
2047 v8::Local<v8::String> prop_name = v8_str("prop_name");
2054 CHECK(obj->SetHiddenValue(key, v8::Integer::New(1503)));
2056 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002)));
2066 CHECK(obj->Set(empty, v8::Integer::New(2003)));
2074 CHECK(obj->Set(prop_name, v8::Integer::New(2008)));
2092 v8::HandleScope scope;
2095 v8::Local<v8::Object> obj = v8::Object::New();
2096 v8::Local<v8::String> key = v8_str("hidden");
2110 CHECK(obj->SetHiddenValue(key, v8::Integer::New(42)));
2117 static v8::Handle<Value> InterceptorForHiddenProperties(
2120 return v8::Handle<Value>();
2125 v8::HandleScope scope;
2130 v8::Local<v8::String> key = v8_str("api-test::hidden-key");
2133 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
2134 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate();
2136 Local<v8::Function> function = fun_templ->GetFunction();
2137 Local<v8::Object> obj = function->NewInstance();
2138 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2302)));
2145 v8::HandleScope scope;
2147 Local<v8::External> ext = v8::External::New(&x);
2151 v8::Handle<v8::External> reext = reext_obj.As<v8::External>();
2159 Local<v8::Value> zero = v8::External::Wrap(&data[0]);
2160 Local<v8::Value> one = v8::External::Wrap(&data[1]);
2161 Local<v8::Value> two = v8::External::Wrap(&data[2]);
2162 Local<v8::Value> three = v8::External::Wrap(&data[3]);
2164 char* char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(zero));
2166 char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(one));
2168 char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(two));
2170 char_ptr = reinterpret_cast<char*>(v8::External::Unwrap(three));
2177 v8::Persistent<String> global;
2179 v8::HandleScope scope;
2181 global = v8::Persistent<String>::New(str);
2249 V8::AddObjectGroup(g1_objects, 2);
2250 V8::AddImplicitReferences(g1s1, g1_children, 1);
2251 V8::AddObjectGroup(g2_objects, 2);
2252 V8::AddImplicitReferences(g2s2, g2_children, 1);
2273 V8::AddObjectGroup(g1_objects, 2);
2274 V8::AddImplicitReferences(g1s1, g1_children, 1);
2275 V8::AddObjectGroup(g2_objects, 2);
2276 V8::AddImplicitReferences(g2s2, g2_children, 1);
2336 V8::AddObjectGroup(g1_objects, 2);
2337 V8::AddImplicitReferences(g1s1, g1_children, 1);
2338 V8::AddObjectGroup(g2_objects, 2);
2339 V8::AddImplicitReferences(g2s1, g2_children, 1);
2340 V8::AddObjectGroup(g3_objects, 2);
2341 V8::AddImplicitReferences(g3s1, g3_children, 1);
2360 V8::AddObjectGroup(g1_objects, 2);
2361 V8::AddImplicitReferences(g1s1, g1_children, 1);
2362 V8::AddObjectGroup(g2_objects, 2);
2363 V8::AddImplicitReferences(g2s1, g2_children, 1);
2364 V8::AddObjectGroup(g3_objects, 2);
2365 V8::AddImplicitReferences(g3s1, g3_children, 1);
2376 v8::HandleScope scope;
2379 v8::TryCatch try_catch;
2391 static void check_message(v8::Handle<v8::Message> message,
2392 v8::Handle<Value> data) {
2402 v8::HandleScope scope;
2404 v8::V8::AddMessageListener(check_message, v8_num(5.76));
2406 v8::ScriptOrigin origin =
2407 v8::ScriptOrigin(v8_str("6.75"));
2408 v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"),
2414 v8::V8::RemoveMessageListeners(check_message);
2419 v8::HandleScope scope;
2423 context->Global()->Set(v8::Integer::New(16), v8_num(32));
2433 CHECK_EQ(92, context->Global()->Get(v8::Integer::New(12))->Int32Value());
2436 CHECK_EQ(32, context->Global()->Get(v8::Integer::New(16))->Int32Value());
2439 CHECK_EQ(56, context->Global()->Get(v8::Integer::New(13))->Int32Value());
2446 v8::HandleScope scope;
2451 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(prop));
2454 context->Global()->Set(prop, v8_num(7), v8::ReadOnly);
2456 CHECK_EQ(v8::ReadOnly, context->Global()->GetPropertyAttributes(prop));
2463 context->Global()->Set(prop, v8_num(13), v8::DontDelete);
2467 CHECK_EQ(v8::DontDelete, context->Global()->GetPropertyAttributes(prop));
2470 context->Global()->Set(prop, v8_num(28), v8::DontEnum);
2471 CHECK_EQ(v8::DontEnum, context->Global()->GetPropertyAttributes(prop));
2474 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(prop));
2476 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(fake_prop));
2481 CHECK_EQ(v8::None, context->Global()->GetPropertyAttributes(exception));
2490 v8::HandleScope scope;
2492 Local<v8::Array> array = v8::Array::New();
2505 Local<v8::Array> arr = obj.As<v8::Array>();
2510 array = v8::Array::New(27);
2512 array = v8::Array::New(-27);
2517 v8::Handle<Value> HandleF(const v8::Arguments& args) {
2518 v8::HandleScope scope;
2520 Local<v8::Array> result = v8::Array::New(args.Length());
2528 v8::HandleScope scope;
2530 global->Set(v8_str("f"), v8::FunctionTemplate::New(HandleF));
2534 Local<v8::Array> a0 = CompileRun(fun).As<v8::Array>();
2538 Local<v8::Array> a1 = CompileRun(fun2).As<v8::Array>();
2543 Local<v8::Array> a2 = CompileRun(fun3).As<v8::Array>();
2549 Local<v8::Array> a3 = CompileRun(fun4).As<v8::Array>();
2556 Local<v8::Array> a4 = CompileRun(fun5).As<v8::Array>();
2566 v8::HandleScope scope;
2579 v8::Handle<Value>* args0 = NULL;
2580 Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->Call(Foo, 0, args0));
2583 v8::Handle<Value> args1[] = { v8_num(1.1) };
2584 Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->Call(Foo, 1, args1));
2586 CHECK_EQ(1.1, a1->Get(v8::Integer::New(0))->NumberValue());
2588 v8::Handle<Value> args2[] = { v8_num(2.2),
2590 Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->Call(Foo, 2, args2));
2592 CHECK_EQ(2.2, a2->Get(v8::Integer::New(0))->NumberValue());
2593 CHECK_EQ(3.3, a2->Get(v8::Integer::New(1))->NumberValue());
2595 v8::Handle<Value> args3[] = { v8_num(4.4),
2598 Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->Call(Foo, 3, args3));
2600 CHECK_EQ(4.4, a3->Get(v8::Integer::New(0))->NumberValue());
2601 CHECK_EQ(5.5, a3->Get(v8::Integer::New(1))->NumberValue());
2602 CHECK_EQ(6.6, a3->Get(v8::Integer::New(2))->NumberValue());
2604 v8::Handle<Value> args4[] = { v8_num(7.7),
2608 Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->Call(Foo, 4, args4));
2610 CHECK_EQ(7.7, a4->Get(v8::Integer::New(0))->NumberValue());
2611 CHECK_EQ(8.8, a4->Get(v8::Integer::New(1))->NumberValue());
2612 CHECK_EQ(9.9, a4->Get(v8::Integer::New(2))->NumberValue());
2613 CHECK_EQ(10.11, a4->Get(v8::Integer::New(3))->NumberValue());
2628 v8::ResourceConstraints constraints;
2631 v8::SetResourceConstraints(&constraints);
2634 v8::HandleScope scope;
2636 v8::V8::IgnoreOutOfMemoryException();
2647 v8::Handle<Value> ProvokeOutOfMemory(const v8::Arguments& args) {
2650 v8::HandleScope scope;
2669 v8::ResourceConstraints constraints;
2672 v8::SetResourceConstraints(&constraints);
2674 v8::HandleScope scope;
2677 v8::FunctionTemplate::New(ProvokeOutOfMemory));
2679 v8::V8::IgnoreOutOfMemoryException();
2698 v8::ResourceConstraints constraints;
2701 v8::SetResourceConstraints(&constraints);
2704 v8::V8::IgnoreOutOfMemoryException();
2706 v8::HandleScope scope;
2721 v8::HandleScope scope;
2734 v8::Handle<Value>* args0 = NULL;
2735 Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->NewInstance(0, args0));
2738 v8::Handle<Value> args1[] = { v8_num(1.1) };
2739 Local<v8::Array> a1 = Local<v8::Array>::Cast(Foo->NewInstance(1, args1));
2741 CHECK_EQ(1.1, a1->Get(v8::Integer::New(0))->NumberValue());
2743 v8::Handle<Value> args2[] = { v8_num(2.2),
2745 Local<v8::Array> a2 = Local<v8::Array>::Cast(Foo->NewInstance(2, args2));
2747 CHECK_EQ(2.2, a2->Get(v8::Integer::New(0))->NumberValue());
2748 CHECK_EQ(3.3, a2->Get(v8::Integer::New(1))->NumberValue());
2750 v8::Handle<Value> args3[] = { v8_num(4.4),
2753 Local<v8::Array> a3 = Local<v8::Array>::Cast(Foo->NewInstance(3, args3));
2755 CHECK_EQ(4.4, a3->Get(v8::Integer::New(0))->NumberValue());
2756 CHECK_EQ(5.5, a3->Get(v8::Integer::New(1))->NumberValue());
2757 CHECK_EQ(6.6, a3->Get(v8::Integer::New(2))->NumberValue());
2759 v8::Handle<Value> args4[] = { v8_num(7.7),
2763 Local<v8::Array> a4 = Local<v8::Array>::Cast(Foo->NewInstance(4, args4));
2765 CHECK_EQ(7.7, a4->Get(v8::Integer::New(0))->NumberValue());
2766 CHECK_EQ(8.8, a4->Get(v8::Integer::New(1))->NumberValue());
2767 CHECK_EQ(9.9, a4->Get(v8::Integer::New(2))->NumberValue());
2768 CHECK_EQ(10.11, a4->Get(v8::Integer::New(3))->NumberValue());
2772 static void CheckUncle(v8::TryCatch* try_catch) {
2781 v8::HandleScope scope;
2829 v8::HandleScope scope;
2880 v8::HandleScope scope;
2888 v8::TryCatch try_catch;
2910 Local<Value> to_object_result = v8::Undefined()->ToObject();
2933 v8::Handle<Value> ThrowFromC(const v8::Arguments& args) {
2935 return v8::ThrowException(v8_str("konto"));
2939 v8::Handle<Value> CCatcher(const v8::Arguments& args) {
2940 if (args.Length() < 1) return v8::False();
2941 v8::HandleScope scope;
2942 v8::TryCatch try_catch;
2943 Local<Value> result = v8::Script::Compile(args[0]->ToString())->Run();
2945 return v8::Boolean::New(try_catch.HasCaught());
2950 v8::HandleScope scope;
2953 v8::FunctionTemplate::New(ThrowFromC));
2968 v8::HandleScope scope;
2971 v8::FunctionTemplate::New(ThrowFromC));
2973 v8::TryCatch try_catch;
2987 v8::HandleScope scope;
2990 v8::FunctionTemplate::New(CCatcher));
3004 v8::Handle<v8::Message> message,
3005 v8::Handle<v8::Value> data) {
3011 static v8::Handle<Value> Fail(const v8::Arguments& args) {
3014 return v8::Undefined();
3022 v8::HandleScope scope;
3023 v8::V8::AddMessageListener(check_reference_error_message);
3025 templ->Set(v8_str("fail"), v8::FunctionTemplate::New(Fail));
3048 v8::Handle<Value> string = CompileRun("try { asdf; } catch(e) { e + ''; }");
3055 v8::V8::RemoveMessageListeners(check_message);
3059 static void receive_message(v8::Handle<v8::Message> message,
3060 v8::Handle<v8::Value> data) {
3068 v8::HandleScope scope;
3069 v8::V8::AddMessageListener(receive_message);
3072 v8::FunctionTemplate::New(ThrowFromC));
3076 v8::V8::RemoveMessageListeners(check_message);
3082 v8::HandleScope scope;
3083 v8::V8::AddMessageListener(receive_message);
3086 v8::FunctionTemplate::New(ThrowFromC));
3088 v8::TryCatch try_catch;
3094 v8::V8::RemoveMessageListeners(check_message);
3100 v8::HandleScope scope;
3101 v8::V8::AddMessageListener(receive_message);
3103 v8::TryCatch try_catch;
3109 v8::V8::RemoveMessageListeners(receive_message);
3114 v8::HandleScope scope;
3117 v8::FunctionTemplate::New(ThrowFromC));
3120 v8::TryCatch try_catch;
3132 v8::Handle<Value> CThrowCountDown(const v8::Arguments& args) {
3138 return v8::ThrowException(v8_str("FromC"));
3140 Local<v8::Object> global = Context::GetCurrent()->Global();
3142 v8::Handle<Value> argv[] = { v8_num(count - 1),
3147 v8::TryCatch try_catch;
3165 v8::Handle<Value> JSCheck(const v8::Arguments& args) {
3176 return v8::Undefined();
3181 v8::HandleScope scope;
3183 v8::TryCatch try_catch;
3216 v8::HandleScope scope;
3218 templ->Set(v8_str("check"), v8::FunctionTemplate::New(JSCheck));
3220 v8::FunctionTemplate::New(CThrowCountDown));
3247 v8::Handle<Value> a0[argc] = { v8_num(4), v8_num(2), v8_num(3), v8_num(2) };
3251 v8::Handle<Value> a1[argc] = { v8_num(5), v8_num(6), v8_num(1), v8_num(2) };
3255 v8::Handle<Value> a2[argc] = { v8_num(6), v8_num(7), v8_num(5), v8_num(5) };
3259 v8::Handle<Value> a3[argc] = { v8_num(6), v8_num(6), v8_num(7), v8_num(6) };
3263 v8::Handle<Value> a4[argc] = { v8_num(6), v8_num(4), v8_num(5), v8_num(4) };
3267 v8::Handle<Value> a5[argc] = { v8_num(6), v8_num(4), v8_num(3), v8_num(3) };
3272 v8::Handle<Value> ThrowValue(const v8::Arguments& args) {
3275 return v8::ThrowException(args[0]);
3280 v8::HandleScope scope;
3282 templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(ThrowValue));
3284 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
3295 CHECK(result->Get(v8::Integer::New(0))->IsString());
3296 CHECK(result->Get(v8::Integer::New(1))->IsNumber());
3297 CHECK_EQ(1, result->Get(v8::Integer::New(1))->Int32Value());
3298 CHECK(result->Get(v8::Integer::New(2))->IsNumber());
3299 CHECK_EQ(0, result->Get(v8::Integer::New(2))->Int32Value());
3300 CHECK(result->Get(v8::Integer::New(3))->IsNull());
3301 CHECK(result->Get(v8::Integer::New(4))->IsUndefined());
3306 v8::HandleScope scope;
3308 v8::TryCatch try_catch;
3322 v8::HandleScope scope;
3324 v8::TryCatch try_catch;
3332 v8::HandleScope scope;
3334 v8::TryCatch try_catch;
3342 v8::Handle<v8::Value> WithTryCatch(const v8::Arguments& args) {
3343 v8::TryCatch try_catch;
3344 return v8::Undefined();
3349 v8::HandleScope scope;
3353 v8::FunctionTemplate::New(WithTryCatch)->GetFunction());
3354 v8::TryCatch try_catch;
3367 v8::HandleScope scope;
3388 CHECK(v8::False()->StrictEquals(v8::False()));
3389 CHECK(!v8::False()->StrictEquals(v8::Undefined()));
3391 v8::Handle<v8::Object> obj = v8::Object::New();
3392 v8::Persistent<v8::Object> alias = v8::Persistent<v8::Object>::New(obj);
3399 v8::HandleScope scope;
3407 static v8::Handle<Value> GetXValue(Local<String> name,
3417 v8::HandleScope scope;
3430 v8::HandleScope scope;
3469 v8::TryCatch try_catch;
3477 v8::HandleScope scope;
3514 v8::TryCatch try_catch;
3522 static v8::Handle<v8::Object> GetGlobalProperty(LocalContext* context,
3524 return v8::Handle<v8::Object>::Cast((*context)->Global()->Get(v8_str(name)));
3529 v8::HandleScope scope;
3603 v8::HandleScope scope;
3613 v8_str("donut"), v8::DEFAULT, v8::DontDelete));
3617 v8_str("donut"), v8::DEFAULT, v8::DontDelete));
3631 v8::TryCatch try_catch;
3639 v8::TryCatch try_catch;
3649 static v8::Handle<Value> Get239Value(Local<String> name,
3659 v8::HandleScope scope;
3682 v8::Persistent<Value> xValue;
3692 xValue = v8::Persistent<Value>::New(value);
3697 v8::HandleScope scope;
3708 xValue = v8::Persistent<Value>();
3713 static v8::Handle<Value> XPropertyGetter(Local<String> property,
3722 v8::HandleScope scope;
3736 v8::HandleScope scope;
3766 v8::HandleScope scope;
3768 v8::Persistent<Context> context1 = Context::New();
3774 v8::Local<v8::Object> object = templ->NewInstance();
3808 static v8::Handle<Value> SetXOnPrototypeGetter(Local<String> property,
3811 v8::Handle<v8::Value> proto = info.Holder()->GetPrototype();
3812 proto.As<v8::Object>()->Set(v8_str("x"), v8::Integer::New(23));
3813 return v8::Handle<Value>();
3820 v8::HandleScope scope;
3821 Local<v8::FunctionTemplate> function_template = v8::FunctionTemplate::New();
3822 Local<v8::ObjectTemplate> instance_template
3835 static v8::Handle<Value> IndexedPropertyGetter(uint32_t index,
3839 return v8::Handle<Value>(v8_num(625));
3841 return v8::Handle<Value>();
3845 static v8::Handle<Value> IndexedPropertySetter(uint32_t index,
3852 return v8::Handle<Value>();
3857 v8::HandleScope scope;
3886 static v8::Handle<Value> UnboxedDoubleIndexedPropertyGetter(
3891 return v8::Handle<Value>(v8_num(index));
3893 return v8::Handle<Value>();
3897 static v8::Handle<Value> UnboxedDoubleIndexedPropertySetter(
3903 return v8::Handle<Value>(v8_num(index));
3905 return v8::Handle<Value>();
3909 Handle<v8::Array> UnboxedDoubleIndexedPropertyEnumerator(
3917 return Local<v8::Array>(::v8::Array::Cast(*result));
3924 v8::HandleScope scope;
3948 Handle<v8::Array> NonStrictArgsIndexedPropertyEnumerator(
3958 return Local<v8::Array>(static_cast<v8::Array*>(::v8::Object::Cast(*result)));
3962 static v8::Handle<Value> NonStrictIndexedPropertyGetter(
3967 return v8::Handle<Value>(v8_num(index));
3969 return v8::Handle<Value>();
3976 v8::HandleScope scope;
3994 static v8::Handle<Value> IdentityIndexedPropertyGetter(
3997 return v8::Integer::NewFromUnsigned(index);
4002 v8::HandleScope scope;
4023 v8::HandleScope scope;
4046 v8::HandleScope scope;
4051 Local<v8::Object> obj = templ->NewInstance();
4071 v8::HandleScope scope;
4076 Local<v8::Object> obj = templ->NewInstance();
4100 v8::HandleScope scope;
4105 Local<v8::Object> obj = templ->NewInstance();
4123 v8::HandleScope scope;
4128 Local<v8::Object> obj = templ->NewInstance();
4162 v8::HandleScope scope;
4167 Local<v8::Object> obj = templ->NewInstance();
4191 v8::HandleScope scope;
4196 Local<v8::Object> obj = templ->NewInstance();
4221 v8::HandleScope scope;
4226 Local<v8::Object> obj = templ->NewInstance();
4251 v8::HandleScope scope;
4256 Local<v8::Object> obj = templ->NewInstance();
4275 v8::HandleScope scope;
4276 v8::Handle<ObjectTemplate> templ = ObjectTemplate::New();
4277 templ->Set(v8_str("dummy"), v8::FunctionTemplate::New(DummyCallHandler));
4284 v8::Handle<v8::Object> global0 = context0->Global();
4291 v8::Handle<v8::Object> global1 = context1->Global();
4300 v8::Handle<v8::Object> global2 = context2->Global();
4311 v8::HandleScope scope;
4314 v8::Handle<v8::Object> global0 =
4316 v8::Handle<v8::Object> object0 =
4317 global0->Get(v8_str("Object")).As<v8::Object>();
4318 v8::Handle<v8::Object> tostring0 =
4319 object0->Get(v8_str("toString")).As<v8::Object>();
4320 v8::Handle<v8::Object> proto0 =
4321 tostring0->Get(v8_str("__proto__")).As<v8::Object>();
4325 v8::Handle<v8::Object> global1 =
4327 v8::Handle<v8::Object> object1 =
4328 global1->Get(v8_str("Object")).As<v8::Object>();
4329 v8::Handle<v8::Object> tostring1 =
4330 object1->Get(v8_str("toString")).As<v8::Object>();
4331 v8::Handle<v8::Object> proto1 =
4332 tostring1->Get(v8_str("__proto__")).As<v8::Object>();
4344 v8::HandleScope scope;
4361 v8::HandleScope scope;
4364 Local<v8::FunctionTemplate> desc =
4365 v8::FunctionTemplate::New(0, v8::Handle<Value>());
4368 Local<v8::Object> obj = desc->GetFunction()->NewInstance();
4405 v8::HandleScope scope;
4408 Local<v8::FunctionTemplate> desc =
4409 v8::FunctionTemplate::New(0, v8::Handle<Value>());
4412 Local<v8::Object> obj = desc->GetFunction()->NewInstance();
4449 v8::HandleScope scope;
4452 Local<v8::FunctionTemplate> desc =
4453 v8::FunctionTemplate::New(0, v8::Handle<Value>());
4456 Local<v8::Object> obj = desc->GetFunction()->NewInstance();
4464 CHECK_EQ(v8::Integer::New(42), script->Run());
4482 v8::HandleScope scope;
4523 v8::HandleScope scope;
4560 v8::Persistent<String> p_str = v8::Persistent<String>::New(str);
4563 v8::Persistent<Script> p_scr = v8::Persistent<Script>::New(scr);
4566 v8::Persistent<ObjectTemplate> p_templ =
4567 v8::Persistent<ObjectTemplate>::New(templ);
4572 static v8::Handle<Value> HandleLogDelegator(const v8::Arguments& args) {
4574 return v8::Undefined();
4579 v8::HandleScope handle_scope;
4582 v8::FunctionTemplate::New(HandleLogDelegator));
4583 v8::Persistent<Context> context = Context::New(0, global_template);
4597 v8::HandleScope handle_scope;
4598 v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource));
4600 v8::ExtensionConfiguration extensions(1, extension_names);
4601 v8::Handle<Context> context = Context::New(&extensions);
4603 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run();
4604 CHECK_EQ(result, v8::Integer::New(4));
4615 v8::HandleScope handle_scope;
4616 v8::RegisterExtension(new Extension("srclentest_fail",
4619 v8::ExtensionConfiguration extensions(1, extension_names);
4620 v8::Handle<Context> context = Context::New(&extensions);
4628 v8::HandleScope handle_scope;
4631 v8::RegisterExtension(new Extension(extension_name.start(),
4635 v8::ExtensionConfiguration extensions(1, extension_names);
4636 v8::Handle<Context> context = Context::New(&extensions);
4639 v8::Handle<Value> result = Script::Compile(v8_str("Ret54321()"))->Run();
4640 CHECK_EQ(v8::Integer::New(54321), result);
4667 v8::HandleScope handle_scope;
4668 v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1));
4669 v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2));
4671 v8::ExtensionConfiguration extensions(2, extension_names);
4672 v8::Handle<Context> context = Context::New(&extensions);
4674 v8::Handle<Value> result = Script::Compile(v8_str("UseEval1()"))->Run();
4675 CHECK_EQ(result, v8::Integer::New(42));
4677 CHECK_EQ(result, v8::Integer::New(42));
4700 v8::HandleScope handle_scope;
4701 v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1));
4702 v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2));
4704 v8::ExtensionConfiguration extensions(2, extension_names);
4705 v8::Handle<Context> context = Context::New(&extensions);
4707 v8::Handle<Value> result = Script::Compile(v8_str("UseWith1()"))->Run();
4708 CHECK_EQ(result, v8::Integer::New(87));
4710 CHECK_EQ(result, v8::Integer::New(87));
4715 v8::HandleScope handle_scope;
4718 v8::RegisterExtension(extension);
4719 v8::Handle<Context> context = Context::New();
4721 v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run();
4722 CHECK_EQ(result, v8::Integer::New(4));
4733 v8::HandleScope handle_scope;
4734 v8::RegisterExtension(new Extension("syntaxerror",
4737 v8::ExtensionConfiguration extensions(1, extension_names);
4738 v8::Handle<Context> context = Context::New(&extensions);
4750 v8::HandleScope handle_scope;
4751 v8::RegisterExtension(new Extension("exception",
4754 v8::ExtensionConfiguration extensions(1, extension_names);
4755 v8::Handle<Context> context = Context::New(&extensions);
4771 v8::HandleScope handle_scope;
4772 v8::RegisterExtension(new Extension("nativecall",
4775 v8::ExtensionConfiguration extensions(1, extension_names);
4776 v8::Handle<Context> context = Context::New(&extensions);
4778 v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run();
4779 CHECK_EQ(result, v8::Integer::New(3));
4787 v8::InvocationCallback fun = &Echo)
4791 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
4792 v8::Handle<v8::String> name) {
4793 return v8::FunctionTemplate::New(function_);
4796 static v8::Handle<v8::Value> Echo(const v8::Arguments& args) {
4798 return v8::Undefined();
4801 v8::InvocationCallback function_;
4806 v8::HandleScope handle_scope;
4808 v8::RegisterExtension(new NativeFunctionExtension(name,
4811 v8::ExtensionConfiguration extensions(1, extension_names);
4812 v8::Handle<Context> context = Context::New(&extensions);
4814 v8::Handle<Value> result = Script::Compile(v8_str("foo(42);"))->Run();
4815 CHECK_EQ(result, v8::Integer::New(42));
4820 v8::HandleScope handle_scope;
4823 v8::RegisterExtension(new NativeFunctionExtension(name,
4826 v8
4827 v8::Handle<Context> context(Context::New(&extensions));
4833 v8::HandleScope handle_scope;
4837 v8::RegisterExtension(new NativeFunctionExtension(
4841 v8::ExtensionConfiguration extensions(1, extension_names);
4842 v8::Handle<Context> context(Context::New(&extensions));
4848 v8::HandleScope handle_scope;
4849 v8::ExtensionConfiguration config(1, &name);
4864 v8::RegisterExtension(new Extension("E", "this.loaded += 'E';", 1, kEDeps));
4866 v8::RegisterExtension(new Extension("D", "this.loaded += 'D';", 2, kDDeps));
4868 v8::RegisterExtension(new Extension("B", "this.loaded += 'B';", 1, kBCDeps));
4869 v8::RegisterExtension(new Extension("C", "this.loaded += 'C';", 1, kBCDeps));
4870 v8::RegisterExtension(new Extension("A", "this.loaded += 'A';"));
4876 v8::HandleScope handle_scope;
4878 v8::ExtensionConfiguration config(2, exts);
4895 static v8::Handle<Value> CallFun(const v8::Arguments& args) {
4899 return v8::Null();
4908 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
4909 v8::Handle<String> name);
4914 v8::Handle<v8::FunctionTemplate> FunctionExtension::GetNativeFunction(
4915 v8::Handle<String> name) {
4918 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(8));
4920 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(7));
4922 return v8::FunctionTemplate::New(CallFun, v8::Integer::New(6));
4924 return v8::Handle<v8::FunctionTemplate>();
4930 v8::RegisterExtension(new FunctionExtension());
4931 v8::HandleScope handle_scope;
4933 v8::ExtensionConfiguration config(1, exts);
4936 CHECK_EQ(v8::Integer::New(8), Script::Compile(v8_str("Foo(0)"))->Run());
4937 CHECK_EQ(v8::Integer::New(7), Script::Compile(v8_str("Foo(1)"))->Run());
4938 CHECK_EQ(v8::Integer::New(6), Script::Compile(v8_str("Foo(2)"))->Run());
4943 v8::RegisterExtension(new FunctionExtension());
4944 v8::HandleScope handle_scope;
4946 v8::ExtensionConfiguration config(1, exts);
4951 CHECK_EQ(v8::Integer::New(8),
4953 CHECK_EQ(v8::Integer::New(7),
4955 CHECK_EQ(v8::Integer::New(6),
4972 // tests that the fatal error handler gets called. This renders V8
4975 v8::V8::SetFatalErrorHandler(StoringErrorCallback);
4977 v8::RegisterExtension(new Extension("A", "", 1, aDeps));
4979 v8::RegisterExtension(new Extension("B", "", 1, bDeps));
4981 v8::ExtensionConfiguration config(1, bDeps);
4982 v8::Handle<Context> context = Context::New(&config);
5003 v8::HandleScope scope;
5004 v8::V8::SetFatalErrorHandler(OOMCallback);
5015 static void MissingScriptInfoMessageListener(v8::Handle<v8::Message> message,
5016 v8::Handle<Value> data) {
5017 CHECK_EQ(v8::Undefined(), data);
5019 CHECK_EQ(v8::Undefined(), message->GetScriptResourceName());
5026 v8::HandleScope scope;
5028 v8::V8::AddMessageListener(MissingScriptInfoMessageListener);
5030 v8::V8::RemoveMessageListeners(MissingScriptInfoMessageListener);
5050 v8::Handle<Script> getScript() {
5052 script_ = v8::Persistent<Script>::New(v8_compile("({}).blammo"));
5059 v8::Persistent<v8::Object> objects_[kObjectCount];
5060 v8::Persistent<Script> script_;
5063 static void HandleWeakReference(v8::Persistent<v8::Value> obj, void* data) {
5069 v8::Handle<Value> WhammyPropertyGetter(Local<String> name,
5072 static_cast<Whammy*>(v8::Handle<v8::External>::Cast(info.Data())->Value());
5074 v8::Persistent<v8::Object> prev = whammy->objects_[whammy->cursor_];
5076 v8::Handle<v8::Object> obj = v8::Object::New();
5077 v8::Persistent<v8::Object> global = v8::Persistent<v8::Object>::New(obj);
5089 v8::HandleScope handle_scope;
5090 v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New();
5094 v8::External::New(whammy));
5095 const char* extension_list[] = { "v8/gc" };
5096 v8::ExtensionConfiguration extensions(1, extension_list);
5097 v8::Persistent<Context> context = Context::New(&extensions);
5100 v8::Handle<v8::Object> interceptor = templ->NewInstance();
5111 v8::Handle<Value> result = CompileRun(code);
5118 static void DisposeAndSetFlag(v8::Persistent<v8::Value> obj, void* data) {
5126 v8::Persistent<Context> context = Context::New();
5129 v8::Persistent<v8::Object> object_a;
5132 v8::HandleScope handle_scope;
5133 object_a = v8::Persistent<v8::Object>::New(v8::Object::New());
5154 static void ForceScavenge(v8::Persistent<v8::Value> obj, void* data) {
5162 static void ForceMarkSweep(v8::Persistent<v8::Value> obj, void* data) {
5171 v8::Persistent<Context> context = Context::New();
5175 v8::WeakReferenceCallback gc_forcing_callback[kNumberOfGCTypes] =
5183 v8::Persistent<v8::Object> object;
5185 v8::HandleScope handle_scope;
5186 object = v8::Persistent<v8::Object>::New(v8::Object::New());
5198 static void RevivingCallback(v8::Persistent<v8::Value> obj, void* data) {
5205 v8::Persistent<Context> context = Context::New();
5208 v8::Persistent<v8::Object> object;
5210 v8::HandleScope handle_scope;
5211 object = v8::Persistent<v8::Object>::New(v8::Object::New());
5212 object->Set(v8_str("x"), v8::Integer::New(1));
5213 v8::Local<String> y_str = v8_str("y");
5223 v8::HandleScope handle_scope;
5224 v8::Local<String> y_str = v8_str("y");
5225 CHECK_EQ(v8::Integer::New(1), object->Get(v8_str("x")));
5231 v8::Handle<Function> args_fun;
5234 static v8::Handle<Value> ArgumentsTestCallback(const v8::Arguments& args) {
5238 CHECK_EQ(v8::Integer::New(1), args[0]);
5239 CHECK_EQ(v8::Integer::New(2), args[1]);
5240 CHECK_EQ(v8::Integer::New(3), args[2]);
5241 CHECK_EQ(v8::Undefined(), args[3]);
5242 v8::HandleScope scope;
5244 return v8::Undefined();
5249 v8::HandleScope scope;
5250 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New();
5251 global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback));
5258 static v8::Handle<Value> NoBlockGetterX(Local<String> name,
5260 return v8::Handle<Value>();
5264 static v8::Handle<Value> NoBlockGetterI(uint32_t index,
5266 return v8::Handle<Value>();
5270 static v8::Handle<v8::Boolean> PDeleter(Local<String> name,
5273 return v8::Handle<v8::Boolean>(); // not intercepted
5276 return v8::False(); // intercepted, and don't delete the property
5280 static v8::Handle<v8::Boolean> IDeleter(uint32_t index, const AccessorInfo&) {
5282 return v8::Handle<v8::Boolean>(); // not intercepted
5285 return v8::False(); // intercepted, and don't delete the property
5290 v8::HandleScope scope;
5291 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
5315 static v8::Handle<Value> GetK(Local<String> name, const AccessorInfo&) {
5320 return v8::Undefined();
5322 return v8::Handle<Value>();
5326 static v8::Handle<Value> IndexedGetK(uint32_t index, const AccessorInfo&) {
5328 if (index == 0 || index == 1) return v8::Undefined();
5329 return v8::Handle<Value>();
5333 static v8::Handle<v8::Array> NamedEnum(const AccessorInfo&) {
5335 v8::Handle<v8::Array> result = v8::Array::New(3);
5336 result->Set(v8::Integer::New(0), v8_str("foo"));
5337 result->Set(v8::Integer::New(1), v8_str("bar"));
5338 result->Set(v8::Integer::New(2), v8_str("baz"));
5343 static v8::Handle<v8::Array> IndexedEnum(const AccessorInfo&) {
5345 v8::Handle<v8::Array> result = v8::Array::New(2);
5346 result->Set(v8::Integer::New(0), v8_str("0"));
5347 result->Set(v8::Integer::New(1), v8_str("1"));
5353 v8::HandleScope scope;
5354 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
5359 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
5385 CHECK_EQ(v8_str("5"), result->Get(v8::Integer::New(0)));
5386 CHECK_EQ(v8_str("10"), result->Get(v8::Integer::New(1)));
5387 CHECK_EQ(v8_str("140000"), result->Get(v8::Integer::New(2)));
5388 CHECK_EQ(v8_str("4294967295"), result->Get(v8::Integer::New(3)));
5391 CHECK_EQ(v8_str("0"), result->Get(v8::Integer::New(4)));
5392 CHECK_EQ(v8_str("1"), result->Get(v8::Integer::New(5)));
5394 CHECK_EQ(v8_str("a"), result->Get(v8::Integer::New(6)));
5395 CHECK_EQ(v8_str("b"), result->Get(v8::Integer::New(7)));
5396 CHECK_EQ(v8_str("c"), result->Get(v8::Integer::New(8)));
5397 CHECK_EQ(v8_str("4294967296"), result->Get(v8::Integer::New(9)));
5398 CHECK_EQ(v8_str("d"), result->Get(v8::Integer::New(10)));
5399 CHECK_EQ(v8_str("e"), result->Get(v8::Integer::New(11)));
5400 CHECK_EQ(v8_str("30000000000"), result->Get(v8::Integer::New(12)));
5401 CHECK_EQ(v8_str("f"), result->Get(v8::Integer::New(13)));
5403 CHECK_EQ(v8_str("foo"), result->Get(v8::Integer::New(14)));
5404 CHECK_EQ(v8_str("bar"), result->Get(v8::Integer::New(15)));
5405 CHECK_EQ(v8_str("baz"), result->Get(v8::Integer::New(16)));
5413 static v8::Handle<Value> PGetter(Local<String> name, const AccessorInfo& info) {
5416 v8::Handle<v8::Object> global = Context::GetCurrent()->Global();
5427 return v8::Undefined();
5431 static void RunHolderTest(v8::Handle<v8::ObjectTemplate> obj) {
5447 static v8::Handle<Value> PGetter2(Local<String> name,
5451 v8::Handle<v8::Object> global = Context::GetCurrent()->Global();
5462 return v8::Undefined();
5467 v8::HandleScope scope;
5468 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
5480 v8::HandleScope scope;
5481 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
5490 v8::HandleScope scope;
5491 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
5496 v8::HandleScope inner_scope;
5497 v8::Handle<v8::Object> obj = templ->NewInstance();
5500 v8::Handle<Value> value =
5502 CHECK_EQ(v8::True(), value);
5532 i::Handle<i::String> istr(v8::Utils::OpenHandle(*str));
5542 v8::HandleScope scope;
5543 v8::Handle<String> str = v8_str("abcde");
5545 v8::Handle<String> str2 = v8_str("abc\303\260\342\230\203");
5557 v8::Handle<v8::Object> global = Context::GetCurrent()->Global();
5764 Local<v8::Array> a =
5765 Local<v8::Array>::Cast(context->Global()->Get(v8_str(name)));
5766 Local<v8::Array> alens =
5767 Local<v8::Array>::Cast(context->Global()->Get(v8_str(lengths_name)));
5769 Local<v8::String> string =
5770 Local<v8::String>::Cast(a->Get(i));
5771 Local<v8::Number> expected_len =
5772 Local<v8::Number>::Cast(alens->Get(i));
5783 v8::Utils::OpenHandle(String::Cast(*str));
5793 Local<v8::Array> b =
5794 Local<v8::Array>::Cast(context->Global()->Get(v8_str(name)));
5795 Local<v8::Array> alens =
5796 Local<v8::Array>::Cast(context->Global()->Get(v8_str(lengths_name)));
5800 Local<v8::String> string =
5801 Local<v8::String>::Cast(b->Get(i));
5802 Local<v8::Number> expected_len =
5803 Local<v8::Number>::Cast(alens->Get(i));
5861 v8::HandleScope scope;
5912 i::Handle<i::String> is1(v8::Utils::OpenHandle(*s1));
5913 i::Handle<i::String> is2(v8::Utils::OpenHandle(*s2));
5919 Handle<String> symbol1 = v8::String::NewSymbol(a);
5920 Handle<String> symbol2 = v8::String::NewSymbol(b);
5927 v8::HandleScope scope;
5929 Handle<String> symbol1 = v8::String::NewSymbol("abc");
5930 Handle<String> symbol2 = v8::String::NewSymbol("abc");
5956 Handle<String> sym0 = v8::String::NewSymbol("benedictus");
5957 Handle<String> sym0b = v8::String::NewSymbol("S\303\270ren");
5958 Handle<String> sym1 = v8::String::NewSymbol("\355\240\201\355\260\207");
5959 Handle<String> sym2 = v8::String::NewSymbol("\360\220\220\210");
5960 Handle<String> sym3 = v8::String::NewSymbol("x\355\240\201\355\260\207");
5961 Handle<String> sym4 = v8::String::NewSymbol("x\360\220\220\210");
5962 v8::Local<v8::Object> global = context->Global();
5979 v8::HandleScope scope;
5982 v8::Handle<String> str = v8_str("42");
5983 v8::Handle<v8::Uint32> index = str->ToArrayIndex();
5996 v8::Handle<v8::Number> num = v8::Number::New(1);
6000 num = v8::Number::New(-1);
6003 v8::Handle<v8::Object> obj = v8::Object::New();
6010 v8::HandleScope scope;
6013 v8::Handle<String> foo = v8_str("foo");
6014 v8::Handle<String> message = v8_str("message");
6015 v8::Handle<Value> range_error = v8::Exception::RangeError(foo);
6017 CHECK(range_error.As<v8::Object>()->Get(message)->Equals(foo));
6018 v8::Handle<Value> reference_error = v8::Exception::ReferenceError(foo);
6020 CHECK(reference_error.As<v8::Object>()->Get(message)->Equals(foo));
6021 v8::Handle<Value> syntax_error = v8::Exception::SyntaxError(foo);
6023 CHECK(syntax_error.As<v8::Object>()->Get(message)->Equals(foo));
6024 v8::Handle<Value> type_error = v8::Exception::TypeError(foo);
6026 CHECK(type_error.As<v8::Object>()->Get(message)->Equals(foo));
6027 v8::Handle<Value> error = v8::Exception::Error(foo);
6029 CHECK(error.As<v8::Object>()->Get(message)->Equals(foo));
6033 static v8::Handle<Value> YGetter(Local<String> name, const AccessorInfo& info) {
6050 v8::HandleScope scope;
6051 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
6054 v8::Handle<v8::Object> holder = obj->NewInstance();
6056 v8::Handle<Value> result = CompileRun(
6063 v8::HandleScope scope;
6064 v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New();
6065 v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New();
6066 v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New();
6067 v8::Handle<v8::FunctionTemplate> templs[3] = { templ1, templ2, templ3 };
6068 v8::Handle<v8::TypeSwitch> type_switch = v8::TypeSwitch::New(3, templs);
6070 v8::Handle<v8::Object> obj0 = v8::Object::New();
6071 v8::Handle<v8::Object> obj1 = templ1->GetFunction()->NewInstance();
6072 v8::Handle<v8::Object> obj2 = templ2->GetFunction()->NewInstance();
6073 v8::Handle<v8::Object> obj3 = templ3->GetFunction()->NewInstance();
6089 static bool NamedSecurityTestCallback(Local<v8::Object> global,
6091 v8::AccessType type,
6094 if (type == v8::ACCESS_GET)
6102 static bool IndexedSecurityTestCallback(Local<v8::Object> global,
6104 v8::AccessType type,
6107 if (type == v8::ACCESS_GET)
6116 static v8::Handle<Value> TroubleCallback(const v8::Arguments& args) {
6121 Local<v8::Object> arg_this = Context::GetCurrent()->Global();
6131 static void ApiUncaughtExceptionTestListener(v8::Handle<v8::Message>,
6132 v8::Handle<Value>) {
6141 v8::HandleScope scope;
6143 v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener);
6145 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback);
6146 v8::Local<v8::Object> global = env->Global();
6164 v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener);
6168 static void ExceptionInNativeScriptTestListener(v8::Handle<v8::Message> message,
6169 v8::Handle<Value>) {
6170 v8::Handle<v8::Value> name_val = message->GetScriptResourceName();
6172 v8::String::AsciiValue name(message->GetScriptResourceName());
6175 v8::String::AsciiValue source_line(message->GetSourceLine());
6180 v8::HandleScope scope;
6182 v8::V8::AddMessageListener(ExceptionInNativeScriptTestListener);
6184 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback);
6185 v8::Local<v8::Object> global = env->Global();
6191 "};"), v8::String::New(script_resource_name))->Run();
6195 v8::V8::RemoveMessageListeners(ExceptionInNativeScriptTestListener);
6200 v8::HandleScope scope;
6202 v8::TryCatch try_catch;
6210 v8::HandleScope scope;
6212 v8::TryCatch try_catch;
6231 v8::HandleScope scope0;
6232 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
6236 v8::Persistent<Context> context0 =
6240 v8::Handle<v8::Object> global0 = context0->Global();
6241 v8::Handle<Script> script0 = v8_compile("foo = 111");
6244 v8::Handle<Value> foo0 = global0->Get(v8_str("foo"));
6246 v8::Handle<Value> z0 = global0->Get(v8_str("0"));
6250 v8::HandleScope scope1;
6252 v8::Persistent<Context> context1 =
6256 v8::Handle<v8::Object> global1 = context1->Global();
6259 v8::Handle<Script> script1 =
6263 v8::Handle<Value> foo1 = global0->Get(v8_str("foo"));
6266 v8::Handle<Value> z1 = global0->Get(v8_str("0"));
6271 v8::HandleScope scope2;
6273 v8::Handle<v8::Object> global2 = context2->Global();
6275 v8::Handle<Script> script2 =
6278 v8::Handle<Value> foo2 = global0->Get(v8_str("foo"));
6280 v8::Handle<Value> z2 = global0->Get(v8_str("0"));
6293 v8::HandleScope handle_scope;
6295 v8::Persistent<Context> env2 = Context::New();
6327 v8::TryCatch try_catch;
6338 v8::HandleScope scope;
6340 v8::Persistent<Context> other = Context::New();
6344 v8::Local<Value> other_object;
6356 v8::Local<Script> access_other0 = v8_compile("other.Object");
6357 v8::Local<Script> access_other1 = v8_compile("other[42]");
6371 v8::Local<Script> access_f0 = v8_compile("f.Object");
6372 v8::Local<Script> access_f1 = v8_compile("f[42]");
6406 v8::HandleScope handle_scope;
6408 v8::Persistent<Context> env2 = Context::New();
6439 v8::HandleScope handle_scope;
6441 v8::Persistent<Context> env2 = Context::New();
6474 v8::HandleScope handle_scope;
6476 v8::Persistent<Context> env2 = Context::New();
6507 v8::HandleScope handle_scope;
6509 v8::Persistent<Context> env2 = Context::New();
6511 Local<v8::Object> global1 = env1->Global();
6523 Local<v8::Object> global2 = env2->Global();
6524 global2->Set(v8_str("prop"), v8::Integer::New(1));
6536 v8::Persistent<Context> env3 =
6537 Context::New(0, v8::Handle<v8::ObjectTemplate>(), global2);
6541 Local<v8::Object> global3 = env3->Global();
6545 global3->Set(v8_str("prop"), v8::Integer::New(-1));
6546 global3->Set(v8_str("prop2"), v8::Integer::New(2));
6553 v8::TryCatch try_catch;
6571 v8::HandleScope scope;
6575 v8::Persistent<Context> env2 = Context::New();
6585 v8::Context::Scope scope(env2);
6586 env2->Global()->Set(v8_str("p"), v8::Integer::New(42));
6598 Local<v8::Object> global2 = env2->Global();
6607 v8::Persistent<Context> env3 =
6608 Context::New(0, v8::Handle<v8::ObjectTemplate>(), global2);
6616 v8::Context::Scope scope(env3);
6617 env3->Global()->Set(v8_str("p"), v8::Integer::New(24));
6649 static bool allowed_access_type[v8::ACCESS_KEYS + 1] = { false };
6650 static bool NamedAccessBlocker(Local<v8::Object> global,
6652 v8::AccessType type,
6659 static bool IndexedAccessBlocker(Local<v8::Object> global,
6661 v8::AccessType type,
6669 static v8::Handle<Value> EchoGetter(Local<String> name,
6683 static v8::Handle<Value> UnreachableGetter(Local<String> name,
6686 return v8::Undefined();
6697 v8::HandleScope handle_scope;
6698 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
6707 v8::Handle<Value>(),
6708 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE));
6713 v8::Handle<Value>(),
6714 v8::DEFAULT);
6717 v8::Persistent<Context> context0 = Context::New(NULL, global_template);
6720 v8::Handle<v8::Object> global0 = context0->Global();
6743 v8::HandleScope scope1;
6745 v8::Persistent<Context> context1 = Context::New();
6748 v8::Handle<v8::Object> global1 = context1->Global();
6760 allowed_access_type[v8::ACCESS_HAS] = true;
6767 allowed_access_type[v8::ACCESS_HAS] = false;
6777 allowed_access_type[v8::ACCESS_HAS] = true;
6783 allowed_access_type[v8::ACCESS_HAS] = false;
6793 allowed_access_type[v8::ACCESS_HAS] = true;
6801 allowed_access_type[v8::ACCESS_HAS] = false;
6804 allowed_access_type[v8::ACCESS_HAS] = true;
6805 allowed_access_type[v8::ACCESS_GET] = true;
6815 allowed_access_type[v8::ACCESS_GET] = false;
6816 allowed_access_type[v8::ACCESS_HAS] = false;
6819 allowed_access_type[v8::ACCESS_HAS] = true;
6820 allowed_access_type[v8::ACCESS_SET] = true;
6830 allowed_access_type[v8::ACCESS_SET] = false;
6831 allowed_access_type[v8::ACCESS_HAS] = false;
6834 allowed_access_type[v8::ACCESS_HAS] = true;
6835 allowed_access_type[v8::ACCESS_GET] = true;
6836 allowed_access_type[v8::ACCESS_SET] = true;
6846 allowed_access_type[v8::ACCESS_SET] = false;
6847 allowed_access_type[v8::ACCESS_GET] = false;
6848 allowed_access_type[v8::ACCESS_HAS] = false;
6857 allowed_access_type[v8::ACCESS_HAS] = true;
6862 allowed_access_type[v8::ACCESS_HAS] = false;
6865 allowed_access_type[v8::ACCESS_HAS] = true;
6866 allowed_access_type[v8::ACCESS_GET] = true;
6873 allowed_access_type[v8::ACCESS_GET] = false;
6874 allowed_access_type[v8::ACCESS_HAS] = false;
6877 allowed_access_type[v8::ACCESS_HAS] = true;
6878 allowed_access_type[v8::ACCESS_SET] = true;
6885 allowed_access_type[v8::ACCESS_SET] = false;
6886 allowed_access_type[v8::ACCESS_HAS] = false;
6889 allowed_access_type[v8::ACCESS_HAS] = true;
6890 allowed_access_type[v8::ACCESS_GET] = true;
6891 allowed_access_type[v8::ACCESS_SET] = true;
6898 allowed_access_type[v8::ACCESS_SET] = false;
6899 allowed_access_type[v8::ACCESS_GET] = false;
6900 allowed_access_type[v8::ACCESS_HAS] = false;
6902 v8::Handle<Value> value;
6941 v8::HandleScope handle_scope;
6942 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
6951 v8::Handle<Value>(),
6952 v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE));
6958 v8::Handle<Value>(),
6959 v8::DEFAULT);
6962 v8::Persistent<Context> context0 = Context::New(NULL, global_template);
6965 v8::Handle<v8::Object> global0 = context0->Global();
6967 v8::Persistent<Context> context1 = Context::New();
6969 v8::Handle<v8::Object> global1 = context1->Global();
7002 v8::Handle<Value> value;
7010 static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global,
7012 v8::AccessType type,
7018 static bool GetOwnPropertyNamesIndexedBlocker(Local<v8::Object> global,
7020 v8::AccessType type,
7027 v8::HandleScope handle_scope;
7028 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New();
7030 obj_template->Set(v8_str("x"), v8::Integer::New(42));
7035 v8::Persistent<Context> context0 = Context::New(NULL, obj_template);
7038 v8::Handle<v8::Object> global0 = context0->Global();
7040 v8::HandleScope scope1;
7042 v8::Persistent<Context> context1 = Context::New();
7045 v8::Handle<v8::Object> global1 = context1->Global();
7049 v8::Handle<Value> value;
7069 static v8::Handle<v8::Array> NamedPropertyEnumerator(const AccessorInfo& info) {
7070 v8::Handle<v8::Array> result = v8::Array::New(1);
7077 v8::HandleScope handle_scope;
7078 v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New();
7080 obj_template->Set(v8_str("x"), v8::Integer::New(42));
7085 v8::Handle<v8::Object> global = context->Global();
7088 v8::Handle<Value> value =
7094 static v8::Handle<Value> ConstTenGetter(Local<String> name,
7101 v8::HandleScope handle_scope;
7103 v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
7105 v8::Handle<v8::ObjectTemplate> global_template =
7108 v8::Handle<v8::ObjectTemplate> proto_template =
7114 v8::Handle<Value>(),
7115 v8::ALL_CAN_READ);
7120 v8::Handle<Value>(),
7121 v8::DEFAULT);
7123 v8::Persistent<Context> context0 = Context::New(NULL, global_template);
7126 Local<v8::Object> global = context0->Global();
7131 v8::HandleScope scope1;
7132 v8::Persistent<Context> context1 = Context::New();
7135 v8::Handle<v8::Object> global1 = context1->Global();
7139 v8::Handle<Value> value = v8_compile("other.accessible")->Run();
7156 static bool NamedAccessCounter(Local<v8::Object> global,
7158 v8::AccessType type,
7165 static bool IndexedAccessCounter(Local<v8::Object> global,
7167 v8::AccessType type,
7179 v8::HandleScope handle_scope;
7182 v8::Persistent<Context> context0 = Context::New();
7187 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New();
7190 Local<v8::Object> object = object_template->NewInstance();
7192 v8::HandleScope scope1;
7195 v8::Persistent<Context> context1 = Context::New();
7199 v8::Handle<v8::Object> global1 = context1->Global();
7202 v8::Handle<Value> value;
7288 static bool NamedAccessFlatten(Local<v8::Object> global,
7290 v8::AccessType type,
7311 static bool IndexedAccessFlatten(Local<v8::Object> global,
7313 v8::AccessType type,
7328 v8::HandleScope handle_scope;
7331 v8::Persistent<Context> context0 = Context::New();
7336 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New();
7339 Local<v8::Object> object = object_template->NewInstance();
7341 v8::HandleScope scope1;
7344 v8::Persistent<Context> context1 = Context::New();
7348 v8::Handle<v8::Object> global1 = context1->Global();
7351 v8::Handle<Value> value;
7363 static v8::Handle<Value> AccessControlNamedGetter(
7365 return v8::Integer::New(42);
7369 static v8::Handle<Value> AccessControlNamedSetter(
7375 static v8::Handle<Value> AccessControlIndexedGetter(
7382 static v8::Handle<Value> AccessControlIndexedSetter(
7392 v8::HandleScope handle_scope;
7395 v8::Persistent<Context> context0 = Context::New();
7401 v8::Handle<v8::ObjectTemplate> object_template = v8::ObjectTemplate::New();
7408 Local<v8::Object> object = object_template->NewInstance();
7410 v8::HandleScope scope1;
7413 v8::Persistent<Context> context1 = Context::New();
7417 v8::Handle<v8::Object> global1 = context1->Global();
7420 v8::Handle<Value> value;
7456 v8::V8::GetVersion();
7460 static v8::Handle<Value> InstanceFunctionCallback(const v8::Arguments& args) {
7467 v8::HandleScope handle_scope;
7470 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
7475 v8::FunctionTemplate::New(InstanceFunctionCallback));
7488 static v8::Handle<Value>
7491 return v8::Handle<Value>();
7496 v8::HandleScope handle_scope;
7500 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
7506 v8::FunctionTemplate::New(InstanceFunctionCallback));
7552 v8::HandleScope handle_scope;
7556 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
7591 static v8::Handle<Value> ShadowFunctionCallback(const v8::Arguments& args) {
7608 static v8::Handle<Value> ShadowYGetter(Local<String> name,
7616 static v8::Handle<Value> ShadowIndexedGet(uint32_t index,
7618 return v8::Handle<Value>();
7622 static v8::Handle<Value> ShadowNamedGet(Local<String> key,
7624 return v8::Handle<Value>();
7630 v8::HandleScope handle_scope;
7632 Local<ObjectTemplate> global_template = v8::ObjectTemplate::New();
7635 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
7642 Local<v8::Signature> signature = v8::Signature::New(t);
7644 v8::FunctionTemplate::New(ShadowFunctionCallback,
7674 v8::HandleScope handle_scope;
7677 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
7679 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
7682 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
7685 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
7688 Local<v8::Object> o0 = t0->GetFunction()->NewInstance();
7689 Local<v8::Object> o1 = t1->GetFunction()->NewInstance();
7690 Local<v8::Object> o2 = t2->GetFunction()->NewInstance();
7691 Local<v8::Object> o3 = t3->GetFunction()->NewInstance();
7713 CHECK(proto.As<v8::Object>()->Get(v8_str("z"))->IsUndefined());
7718 v8::HandleScope handle_scope;
7721 Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
7723 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
7726 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
7729 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
7732 Local<v8::Object> o0 = t0->GetFunction()->NewInstance();
7733 Local<v8::Object> o1 = t1->GetFunction()->NewInstance();
7734 Local<v8::Object> o2 = t2->GetFunction()->NewInstance();
7735 Local<v8::Object> o3 = t3->GetFunction()->NewInstance();
7757 CHECK_EQ(proto.As<v8::Object>(), o3);
7762 CHECK_EQ(proto0.As<v8::Object>(), o1);
7766 CHECK_EQ(proto1.As<v8::Object>(), o2);
7770 CHECK_EQ(proto2.As<v8::Object>(), o3);
7779 v8::HandleScope handle_scope;
7782 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
7785 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
7788 t2->InstanceTemplate()->Set(v8_str("objects"), v8::Object::New());
7790 Local<v8::FunctionTemplate> t3 = v8::FunctionTemplate::New();
7793 Local<v8::FunctionTemplate> t4 = v8::FunctionTemplate::New();
7803 Local<v8::Object> o1 = t1->GetFunction()->NewInstance();
7804 Local<v8::Object> o2 = t2->GetFunction()->NewInstance();
7805 Local<v8::Object> o3 = t3->GetFunction()->NewInstance();
7806 Local<v8::Object> o4 = t4->GetFunction()->NewInstance();
7829 v8::HandleScope handle_scope;
7832 Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
7833 t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42));
7846 Local<v8::FunctionTemplate> t2 = v8::FunctionTemplate::New();
7847 t2->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42));
7860 v8::HandleScope handle_scope;
7863 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
7865 Local<v8::Object> o0 = t->GetFunction()->NewInstance();
7866 Local<v8::Object> o1 = t->GetFunction()->NewInstance();
7871 v8::TryCatch try_catch;
7881 v8::HandleScope handle_scope;
7889 Local<v8::Object> x =
7890 Local<v8::Object>::Cast(context->Global()->Get(v8_str("x")));
7891 v8::TryCatch try_catch;
7892 x->Set(v8_str("set"), v8::Integer::New(8));
7894 x->Set(v8_str("set"), v8::Integer::New(8));
7896 x->Set(v8_str("set"), v8::Integer::New(8));
7898 x->Set(v8_str("set"), v8::Integer::New(8));
7904 v8::HandleScope handle_scope;
7906 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
7910 Local<v8::Object> inst = cons->NewInstance();
7911 i::Handle<i::JSObject> obj(v8::Utils::OpenHandle(*inst));
7945 v8::HandleScope handle_scope;
7952 v8::TryCatch try_catch;
7995 Handle<Value> args3[] = { v8::True() };
8005 Handle<Value> args4[] = { v8::Undefined() };
8014 Handle<Value> args5[] = { v8::Null() };
8027 v8::TryCatch try_catch;
8050 v8::TryCatch try_catch;
8074 v8::TryCatch try_catch;
8112 v8::HandleScope handle_scope;
8114 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
8137 v8::HandleScope scope;
8157 v8::TryCatch try_catch;
8173 v8::HandleScope scope;
8202 v8::TryCatch try_catch;
8256 v8::HandleScope scope;
8258 v8::Persistent<Context> context0 = Context::New();
8259 v8::Persistent<Context> context1 = Context::New();
8263 v8::Handle<v8::Value> fun =
8276 v8::Handle<v8::Value> x_value = CompileRun("fun('x')");
8279 v8::TryCatch catcher;
8291 v8::HandleScope scope;
8310 static v8::Handle<Value> call_as_function(const v8::Arguments& args) {
8326 v8::HandleScope scope;
8329 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
8332 Local<v8::Object> instance = t->GetFunction()->NewInstance();
8334 v8::TryCatch try_catch;
8376 v8::Handle<Value> args[] = { v8_num(28) };
8382 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
8385 Local<v8::Object> instance = t->GetFunction()->NewInstance();
8387 v8::TryCatch try_catch;
8402 v8::Handle<Value> args[] = { v8_num(28) };
8411 { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
8414 Local<v8::Object> instance = t->GetFunction()->NewInstance();
8416 v8::TryCatch try_catch;
8427 v8::Handle<Value> args[] = { v8_num(23) };
8439 v8::HandleScope scope;
8445 v8::TryCatch try_catch;
8453 v8::TryCatch try_catch;
8463 v8::TryCatch try_catch;
8472 v8::TryCatch try_catch;
8481 return v8::HandleScope::NumberOfHandles();
8486 v8::HandleScope scope;
8489 Local<v8::Number> n(v8::Integer::New(42));
8500 v8::HandleScope scope1;
8503 Local<v8::Number> n(v8::Integer::New(42));
8509 v8::HandleScope scope2;
8511 Local<v8::Number> n(v8::Integer::New(42));
8522 static v8::Handle<Value> InterceptorHasOwnPropertyGetter(
8526 return v8::Handle<Value>();
8531 v8::HandleScope scope;
8533 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
8534 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate();
8538 v8::Handle<Value> value = CompileRun(
8553 static v8::Handle<Value> InterceptorHasOwnPropertyGetterGC(
8558 return v8::Handle<Value>();
8563 v8::HandleScope scope;
8565 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
8566 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate();
8583 v8::Handle<Value> value = CompileRun(
8591 typedef v8::Handle<Value> (*NamedPropertyGetter)(Local<String> property,
8598 v8::HandleScope scope;
8599 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
8603 v8::Handle<Value> value = CompileRun(source);
8608 static v8::Handle<Value> InterceptorLoadICGetter(Local<String> name,
8613 return v8::Integer::New(42);
8632 static v8::Handle<Value> InterceptorLoadXICGetter(Local<String> name,
8636 ? v8::Integer::New(42) : v8::Handle<v8::Value>();
8745 static v8::Handle<Value> InterceptorLoadNotHandled(Local<String> name,
8748 return v8::Handle<v8::Value>();
8805 v8::HandleScope scope;
8806 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
8814 v8::Handle<Value> value = CompileRun(
8834 v8::HandleScope scope;
8835 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
8837 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New();
8846 v8::Handle<Value> value = CompileRun(
8867 v8::HandleScope scope;
8868 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
8875 v8::Handle<Value> value = CompileRun(
8895 v8::HandleScope scope;
8896 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
8898 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New();
8905 v8::Handle<Value> value = CompileRun(
8923 v8::HandleScope scope;
8924 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
8926 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New();
8933 v8::Handle<Value> value = CompileRun(
8955 v8::HandleScope scope;
8956 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
8958 v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New();
8965 v8::Handle<Value> value = CompileRun(
8982 static v8::Handle<Value> InterceptorLoadICGetter0(Local<String> name,
8986 return v8::Integer::New(0);
8997 static v8::Handle<Value> InterceptorStoreICSetter(
9007 v8::HandleScope scope;
9008 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9022 v8::HandleScope scope;
9023 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9027 v8::Handle<Value> value = CompileRun(
9038 v8::Handle<Value> call_ic_function;
9039 v8::Handle<Value> call_ic_function2;
9040 v8::Handle<Value> call_ic_function3;
9042 static v8::Handle<Value> InterceptorCallICGetter(Local<String> name,
9052 v8::HandleScope scope;
9053 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9059 v8::Handle<Value> value = CompileRun(
9071 v8::HandleScope scope;
9072 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9076 v8::Handle<Value> value = CompileRun(
9086 static v8::Handle<Value> call_ic_function4;
9087 static v8::Handle<Value> InterceptorCallICGetter4(Local<String> name,
9099 v8::HandleScope scope;
9100 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9106 v8::Handle<Value> value = CompileRun(
9119 v8::HandleScope scope;
9120 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9124 v8::Handle<Value> value = CompileRun(
9146 v8::HandleScope scope;
9147 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9151 v8::Handle<Value> value = CompileRun(
9163 static v8::Handle<Value> call_ic_function5;
9164 static v8::Handle<Value> InterceptorCallICGetter5(Local<String> name,
9178 v8::HandleScope scope;
9179 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9185 v8::Handle<Value> value = CompileRun(
9197 static v8::Handle<Value> call_ic_function6;
9198 static v8::Handle<Value> InterceptorCallICGetter6(Local<String> name,
9212 v8::HandleScope scope;
9213 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9219 v8::Handle<Value> value = CompileRun(
9242 v8::HandleScope scope;
9243 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9247 v8::Handle<Value> value = CompileRun(
9272 v8::HandleScope scope;
9273 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9277 v8::Handle<Value> value = CompileRun(
9297 v8::HandleScope scope;
9298 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
9304 v8::Handle<Value> value = CompileRun(
9323 static v8::Handle<Value> InterceptorCallICFastApi(Local<String> name,
9326 int* call_count = reinterpret_cast<int*>(v8::External::Unwrap(info.Data()));
9331 return v8::Handle<Value>();
9334 static v8::Handle<Value> FastApiCallback_TrivialSignature(
9335 const v8::Arguments& args) {
9339 return v8::Integer::New(args[0]->Int32Value() + 1);
9342 static v8::Handle<Value> FastApiCallback_SimpleSignature(
9343 const v8::Arguments& args) {
9350 return v8::Integer::New(args[0]->Int32Value() + 1);
9364 v8::Handle<v8::Value> DirectApiCallback(const v8::Arguments& args) {
9370 return v8::Handle<v8::Value>();
9375 v8::HandleScope scope;
9377 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New();
9379 v8::FunctionTemplate::New(DirectApiCallback));
9380 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance();
9393 v8::Handle<v8::Value> ThrowingDirectApiCallback(const v8::Arguments& args) {
9394 return v8::ThrowException(v8_str("g"));
9399 v8::HandleScope scope;
9401 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New();
9403 v8::FunctionTemplate::New(ThrowingDirectApiCallback));
9404 v8::Local<v8::Object> nativeobject_obj = nativeobject_templ->NewInstance();
9407 v8::Handle<Value> result = CompileRun(
9419 v8::Handle<v8::Value> DirectGetterCallback(Local<String> name,
9420 const v8::AccessorInfo& info) {
9425 return v8::Handle<v8::Value>();
9430 v8::HandleScope scope;
9432 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New();
9445 v8::Handle<v8::Value> ThrowingDirectGetterCallback(
9446 Local<String> name, const v8::AccessorInfo& info) {
9447 return v8::ThrowException(v8_str("g"));
9452 v8::HandleScope scope;
9454 v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New();
9457 v8::Handle<Value> result = CompileRun(
9469 v8::HandleScope scope;
9470 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9471 v8::Handle<v8::FunctionTemplate> method_templ =
9472 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature,
9474 v8::Handle<v8::Signature>());
9475 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9477 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9480 v8::External::Wrap(&interceptor_call_count));
9482 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9496 v8::HandleScope scope;
9497 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9498 v8::Handle<v8::FunctionTemplate> method_templ =
9499 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9501 v8::Signature::New(fun_templ));
9502 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9504 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9507 v8::External::Wrap(&interceptor_call_count));
9509 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9526 v8::HandleScope scope;
9527 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9528 v8::Handle<v8::FunctionTemplate> method_templ =
9529 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9531 v8::Signature::New(fun_templ));
9532 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9534 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9537 v8::External::Wrap(&interceptor_call_count));
9539 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9562 v8::HandleScope scope;
9563 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9564 v8::Handle<v8::FunctionTemplate> method_templ =
9565 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9567 v8::Signature::New(fun_templ));
9568 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9570 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9573 v8::External::Wrap(&interceptor_call_count));
9575 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9598 v8::HandleScope scope;
9599 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9600 v8::Handle<v8::FunctionTemplate> method_templ =
9601 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9603 v8::Signature::New(fun_templ));
9604 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9606 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9609 v8::External::Wrap(&interceptor_call_count));
9611 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9614 v8::TryCatch try_catch;
9637 v8::HandleScope scope;
9638 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9639 v8::Handle<v8::FunctionTemplate> method_templ =
9640 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9642 v8::Signature::New(fun_templ));
9643 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9645 v8::Handle<v8::ObjectTemplate> templ = fun_templ->InstanceTemplate();
9648 v8::External::Wrap(&interceptor_call_count));
9650 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9653 v8::TryCatch try_catch;
9675 v8::HandleScope scope;
9676 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9677 v8::Handle<v8::FunctionTemplate> method_templ =
9678 v8::FunctionTemplate::New(FastApiCallback_TrivialSignature,
9680 v8::Handle<v8::Signature>());
9681 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9683 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
9686 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9699 v8::HandleScope scope;
9700 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9701 v8::Handle<v8::FunctionTemplate> method_templ =
9702 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9704 v8::Signature::New(fun_templ));
9705 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9707 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
9710 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9726 v8::HandleScope scope;
9727 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9728 v8::Handle<v8::FunctionTemplate> method_templ =
9729 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9731 v8::Signature::New(fun_templ));
9732 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9734 v8v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
9737 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9758 v8::HandleScope scope;
9759 v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
9760 v8::Handle<v8::FunctionTemplate> method_templ =
9761 v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
9763 v8::Signature::New(fun_templ));
9764 v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
9766 v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
9769 v8::Handle<v8::Function> fun = fun_templ->GetFunction();
9772 v8::TryCatch try_catch;
9793 v8::Handle<Value> keyed_call_ic_function;
9795 static v8::Handle<Value> InterceptorKeyedCallICGetter(
9801 return v8::Handle<Value>();
9808 v8::HandleScope scope;
9809 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9832 v8::HandleScope scope;
9833 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9859 v8::HandleScope scope;
9860 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9884 v8::HandleScope scope;
9885 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
9908 v8::HandleScope scope;
9909 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
9930 v8::HandleScope scope;
9931 v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
9952 static v8::Handle<Value> InterceptorICRefErrorGetter(Local<String> name,
9958 return v8::Handle<Value>();
9966 v8::HandleScope scope;
9967 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
9969 LocalContext context(0, templ, v8::Handle<Value>());
9971 v8::Handle<Value> value = CompileRun(
9995 static v8::Handle<Value> InterceptorICExceptionGetter(
10003 return v8::ThrowException(v8_num(42));
10006 return v8::Handle<Value>();
10013 v8::HandleScope scope;
10014 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
10016 LocalContext context(0, templ, v8::Handle<Value>());
10018 v8::Handle<Value> value = CompileRun(
10042 static v8::Handle<Value> InterceptorICExceptionSetter(
10046 return v8::ThrowException(v8_num(42));
10049 return v8::Handle<Value>();
10056 v8::HandleScope scope;
10057 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
10059 LocalContext context(0, templ, v8::Handle<Value>());
10060 v8::Handle<Value> value = CompileRun(
10074 v8::HandleScope scope;
10075 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
10079 v8::Handle<v8::Object> obj = templ->NewInstance();
10081 v8::Handle<Value> value = CompileRun("obj.x");
10089 v8::HandleScope scope;
10090 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
10094 v8::Handle<v8::Object> obj = templ->NewInstance();
10096 v8::Handle<Value> value = CompileRun("obj[42]");
10103 v8::HandleScope scope;
10104 v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
10226 V8::AddMessageListener(callback);
10236 V8::RemoveMessageListeners(callback);
10242 static v8::Handle<Value> ParentGetter(Local<String> name,
10249 static v8::Handle<Value> ChildGetter(Local<String> name,
10257 v8::HandleScope scope;
10261 Local<v8::FunctionTemplate> parent_templ = v8::FunctionTemplate::New();
10267 Local<v8::FunctionTemplate> child_templ = v8::FunctionTemplate::New();
10282 v8::Handle<Value>(), v8::DEFAULT, v8::ReadOnly);
10288 v8::Handle<Value>(), v8::DEFAULT, v8::ReadOnly);
10293 Local<v8::Object> instance = child_templ->GetFunction()->NewInstance();
10313 static v8::Handle<Value> IsConstructHandler(const v8::Arguments& args) {
10315 return v8::Boolean::New(args.IsConstructCall());
10320 v8::HandleScope scope;
10323 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
10337 v8::HandleScope scope;
10338 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
10351 Local<v8::Object> instance = templ->GetFunction()->NewInstance();
10365 value = object.As<v8::Object>()->ObjectProtoToString();
10371 v8::HandleScope scope;
10381 Local<v8::Value> p = context->Global()->Get(v8_str("p"));
10385 Local<v8::Value> c = context->Global()->Get(v8_str("c"));
10389 Local<v8::Value> x = context->Global()->Get(v8_str("x"));
10412 // Let the next thread go. Since it is also waiting on the V8 lock it may
10437 // ... get the V8 lock and start running the test.
10438 v8::Locker locker;
10502 v8::Unlocker unlocker;
10553 static v8::Handle<Value> ThrowInJS(const v8::Arguments& args) {
10554 CHECK(v8::Locker::IsLocked());
10556 v8::Unlocker unlocker;
10559 v8::Locker nested_locker;
10560 v8::HandleScope scope;
10561 v8::Handle<Value> exception;
10562 { v8::TryCatch try_catch;
10563 v8::Handle<Value> value = CompileRun(code);
10571 return v8::ThrowException(exception);
10576 static v8::Handle<Value> ThrowInJSNoCatch(const v8::Arguments& args) {
10577 CHECK(v8::Locker::IsLocked());
10579 v8::Unlocker unlocker;
10582 v8::Locker nested_locker;
10583 v8::HandleScope scope;
10584 v8::Handle<Value> value = CompileRun(code);
10594 v8::Locker locker;
10595 CHECK(v8::Locker::IsLocked());
10596 v8::HandleScope scope;
10598 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(ThrowInJS);
10616 v8::Locker locker;
10617 v8::HandleScope scope;
10619 Local<v8::FunctionTemplate> fun_templ =
10620 v8::FunctionTemplate::New(ThrowInJSNoCatch);
10636 v8::Locker locker;
10638 v8::Locker locker2;
10639 CHECK(v8::Locker::IsLocked());
10644 static v8::Handle<Value> UnlockForAMoment(const v8::Arguments& args) {
10646 v8::Unlocker unlocker;
10647 return v8::Undefined();
10653 v8::Locker locker;
10654 v8::HandleScope scope;
10656 Local<v8::FunctionTemplate> fun_templ =
10657 v8::FunctionTemplate::New(UnlockForAMoment);
10667 v8::Locker locker;
10668 v8::HandleScope scope;
10670 Local<v8::FunctionTemplate> fun_templ =
10671 v8::FunctionTemplate::New(UnlockForAMoment);
10712 v8::V8::Initialize();
10715 { v8::HandleScope scope;
10720 { v8::HandleScope scope;
10726 { v8::HandleScope scope;
10732 { v8::HandleScope scope;
10733 const char* extension_list[] = { "v8/gc" };
10734 v8::ExtensionConfiguration extensions(1, extension_list);
10743 v8::Persistent<v8::Object> some_object;
10744 v8::Persistent<v8::Object> bad_handle;
10746 void NewPersistentHandleCallback(v8::Persistent<v8::Value> handle, void*) {
10747 v8::HandleScope scope;
10748 bad_handle = v8::Persistent<v8::Object>::New(some_object);
10756 v8::Persistent<v8::Object> handle1, handle2;
10758 v8::HandleScope scope;
10759 some_object = v8::Persistent<v8::Object>::New(v8::Object::New());
10760 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New());
10761 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New());
10773 v8::Persistent<v8::Object> to_be_disposed;
10775 void DisposeAndForceGcCallback(v8::Persistent<v8::Value> handle, void*) {
10785 v8::Persistent<v8::Object> handle1, handle2;
10787 v8::HandleScope scope;
10788 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New());
10789 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New());
10796 void DisposingCallback(v8::Persistent<v8::Value> handle, void*) {
10800 void HandleCreatingCallback(v8::Persistent<v8::Value> handle, void*) {
10801 v8::HandleScope scope;
10802 v8::Persistent<v8::Object>::New(v8::Object::New());
10810 v8::Persistent<v8::Object> handle1, handle2, handle3;
10812 v8::HandleScope scope;
10813 handle3 = v8::Persistent<v8::Object>::New(v8::Object::New());
10814 handle2 = v8::Persistent<v8::Object>::New(v8::Object::New());
10815 handle1 = v8::Persistent<v8::Object>::New(v8::Object::New());
10824 v8::V8::Initialize();
10834 { v8::HandleScope scope;
10838 { v8::HandleScope scope;
10846 static v8::Handle<Value> NestedScope(v8::Persistent<Context> env) {
10847 v8::HandleScope inner;
10849 v8::Handle<Value> three = v8_num(3);
10850 v8::Handle<Value> value = inner.Close(three);
10857 v8::HandleScope outer;
10858 v8::Persistent<Context> env = Context::New();
10860 v8::Handle<Value> value = NestedScope(env);
10861 v8::Handle<String> str(value->ToString());
10869 v8::HandleScope outer;
10870 v8::Persistent<Context> env(Context::New());
10873 CHECK_EQ(v8::V8::AdjustAmountOfExternalAllocatedMemory(kSize), kSize);
10874 CHECK_EQ(v8::V8::AdjustAmountOfExternalAllocatedMemory(-kSize), 0);
10879 v8::HandleScope scope;
10881 { v8::Persistent<v8::Context> inner = v8::Context::New();
10894 v8::HandleScope outer;
10896 static v8::Persistent<v8::ObjectTemplate> templ;
10898 v8::HandleScope inner;
10899 v8::Handle<v8::ObjectTemplate> local = v8::ObjectTemplate::New();
10901 templ = v8::Persistent<v8::ObjectTemplate>::New(inner.Close(local));
10903 v8::Handle<v8::Object> result = templ->NewInstance();
10911 v8::HandleScope scope;
10913 v8::TryCatch try_catch;
10914 v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(
10920 v8::Handle<v8::Value> result = script->Run();
10925 static void CheckTryCatchSourceInfo(v8::Handle<v8::Script> script,
10928 v8::HandleScope scope;
10929 v8::TryCatch try_catch;
10930 v8::Handle<v8::Value> result = script->Run();
10933 v8::Handle<v8::Message> message = try_catch.Message();
10940 v8::String::AsciiValue line(message->GetSourceLine());
10942 v8::String::AsciiValue name(message->GetScriptResourceName());
10948 v8::HandleScope scope;
10950 v8::Handle<v8::String> source = v8::String::New(
10966 v8::Handle<v8::Script> script;
10968 script = v8::Script::Compile(source, v8::String::New(resource_name));
10972 v8::ScriptOrigin origin1(v8::String::New(resource_name));
10973 script = v8::Script::Compile(source, &origin1);
10977 v8::ScriptOrigin origin2(v8::String::New(resource_name), v8::Integer::New(7));
10978 script = v8::Script::Compile(source, &origin2);
10984 v8::HandleScope scope;
10986 v8::Handle<v8::String> source0 = v8::String::New("1234");
10987 v8::Handle<v8::String> source1 = v8::String::New("1234");
10988 v8::Handle<v8::Script> script0 =
10989 v8::Script::Compile(source0, v8::String::New("test.js"));
10990 v8::Handle<v8::Script> script1 =
10991 v8::Script::Compile(source1, v8::String::New("test.js"));
10992 v8::Handle<v8::Script> script2 =
10993 v8::Script::Compile(source0); // different origin
11000 static v8::Handle<Value> FunctionNameCallback(const v8::Arguments& args) {
11007 v8::HandleScope scope;
11010 t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback));
11012 v8::Handle<v8::Value> value = CompileRun("obj.asdf.name");
11014 v8::String::AsciiValue name(value);
11020 v8::HandleScope scope;
11022 v8::Handle<v8::Value> date = v8::Date::New(1224744689038.0);
11024 CHECK_EQ(1224744689038.0, date.As<v8::Date>()->NumberValue());
11028 void CheckProperties(v8::Handle<v8::Value> val, int elmc, const char* elmv[]) {
11029 v8::Handle<v8::Object> obj = val.As<v8::Object>();
11030 v8::Handle<v8::Array> props = obj->GetPropertyNames();
11033 v8::String::Utf8Value elm(props->Get(v8::Integer::New(i)));
11039 void CheckOwnProperties(v8::Handle<v8::Value> val,
11042 v8::Handle<v8::Object> obj = val.As<v8::Object>();
11043 v8::Handle<v8::Array> props = obj->GetOwnPropertyNames();
11046 v8::String::Utf8Value elm(props->Get(v8::Integer::New(i)));
11053 v8::HandleScope scope;
11055 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::New(
11064 v8::Handle<v8::Array> elms = obj.As<v8::Array>();
11068 CheckProperties(elms->Get(v8::Integer::New(0)), elmc0, elmv0);
11069 CheckOwnProperties(elms->Get(v8::Integer::New(0)), elmc0, elmv0);
11072 CheckProperties(elms->Get(v8::Integer::New(1)), elmc1, elmv1);
11073 CheckOwnProperties(elms->Get(v8::Integer::New(1)), elmc1, elmv1);
11076 CheckProperties(elms->Get(v8::Integer::New(2)), elmc2, elmv2);
11077 CheckOwnProperties(elms->Get(v8::Integer::New(2)), elmc2, elmv2);
11080 CheckProperties(elms->Get(v8::Integer::New(3)), elmc3, elmv3);
11083 CheckOwnProperties(elms->Get(v8::Integer::New(3)), elmc4, elmv4);
11087 v8::HandleScope scope;
11089 v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::New(
11098 v8::Handle<v8::Array> elms = obj.As<v8::Array>();
11102 CheckProperties(elms->Get(v8::Integer::New(0)), elmc0, elmv0);
11104 v8::Handle<v8::Value> val = elms->Get(v8::Integer::New(0));
11105 v8::Handle<v8::Array> props = val.As<v8::Object>()->GetPropertyNames();
11112 static bool NamedSetAccessBlocker(Local<v8::Object> obj,
11114 v8::AccessType type,
11116 return type != v8::ACCESS_SET;
11120 static bool IndexedSetAccessBlocker(Local<v8::Object> obj,
11122 v8::AccessType type,
11124 return type != v8::ACCESS_SET;
11129 v8::HandleScope scope;
11134 templ->Set(v8_str("x"), v8::True());
11135 Local<v8::Object> instance = templ->NewInstance();
11142 static bool NamedGetAccessBlocker(Local<v8::Object> obj,
11144 v8::AccessType type,
11150 static bool IndexedGetAccessBlocker(Local<v8::Object> obj,
11152 v8::AccessType type,
11160 v8::HandleScope scope;
11177 templ->Set(v8_str(buf), v8::Number::New(k));
11182 Local<v8::Object> instance_1 = templ->NewInstance();
11188 Local<v8::Object> instance_2 = templ->NewInstance();
11199 v8::HandleScope handle_scope;
11200 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
11204 v8::Utils::OpenHandle(*global_template);
11209 v8::Persistent<Context> context0(Context::New(NULL, global_template));
11216 v8::HandleScope handle_scope;
11220 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
11223 v8::Handle<v8::Value>(),
11225 v8::Persistent<Context> context = Context::New(NULL, global_template);
11247 v8::Handle<v8::Object> global = context->Global();
11283 static bool NamedGetAccessBlockAandH(Local<v8::Object> obj,
11285 v8::AccessType type,
11289 v8::Utils::OpenHandle(String::Cast(*name));
11296 v8::HandleScope handle_scope;
11301 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
11304 v8::Handle<v8::Value>(),
11306 v8::Persistent<Context> context = Context::New(NULL, global_template);
11330 v8::Handle<v8::Object> global = context->Global();
11385 // TODO(155): This test would break without the initialization of V8. This is
11387 v8::V8::Initialize();
11389 v8::ScriptData* sd =
11390 v8::ScriptData::PreCompile(script, i::StrLength(script));
11399 v8::V8::Initialize();
11401 v8::ScriptData* sd =
11402 v8::ScriptData::PreCompile(script, i::StrLength(script));
11409 v8::V8::Initialize();
11411 v8::ScriptData* sd =
11412 v8::ScriptData::PreCompile(script, i::StrLength(script));
11420 v8::V8::Initialize();
11422 v8::ScriptData* sd =
11423 v8::ScriptData::PreCompile(script, i::StrLength(script));
11431 v8::ScriptData* deserialized_sd =
11432 v8::ScriptData::New(serialized_data, serialized_data_length);
11446 v8::V8::Initialize();
11449 v8::ScriptData* sd = v8::ScriptData::New(data, invalid_size);
11459 v8::V8::Initialize();
11460 v8::HandleScope scope;
11465 v8::ScriptData* sd =
11466 v8::ScriptData::PreCompile(script, i::StrLength(script));
11478 v8::TryCatch try_catch;
11492 sd = v8::ScriptData::PreCompile(script, i::StrLength(script));
11506 v8::V8::Initialize();
11507 v8::HandleScope scope;
11511 v8::ScriptData* sd_from_cstring =
11512 v8::ScriptData::PreCompile(cstring, i::StrLength(cstring));
11515 v8::ScriptData* sd_from_external_string = v8::ScriptData::PreCompile(
11516 v8::String::NewExternal(resource));
11518 v8::ScriptData* sd_from_string = v8::ScriptData::PreCompile(
11519 v8::String::New(cstring));
11544 v8::HandleScope scope;
11548 context->Global()->Set(v8_str("tmp"), v8::True());
11555 context->Global()->Set(v8_str("tmp"), v8::True());
11565 v8::HandleScope scope;
11566 v8::Persistent<Context> context0 = Context::New();
11567 v8::Persistent<Context> context1 = Context::New();
11607 v8::Locker::StartPreemption(1);
11611 v8::Unlocker unlock;
11614 v8::Locker::StopPreemption();
11638 v8::Locker lock;
11698 v8::Locker lock;
11699 v8::V8::Initialize();
11700 v8::HandleScope scope;
11730 v8::Locker::StartPreemption(1);
11734 v8::Unlocker unlock;
11737 v8::Locker::StopPreemption();
11761 v8::Locker lock;
11807 v8::Locker lock;
11808 v8::V8::Initialize();
11809 v8::HandleScope scope;
11829 v8::HandleScope scope;
11841 Local<v8::Object> obj = val.As<v8::Object>();
11845 CHECK_EQ(v8::Integer::New(123), obj->Get(v8_str("beta")));
11849 Local<v8::Object> clone = obj->Clone();
11851 CHECK_EQ(v8::Integer::New(123), clone->Get(v8_str("beta")));
11855 clone->Set(v8_str("beta"), v8::Integer::New(456));
11856 CHECK_EQ(v8::Integer::New(123), obj->Get(v8_str("beta")));
11857 CHECK_EQ(v8::Integer::New(456), clone->Get(v8_str("beta")));
11861 class AsciiVectorResource : public v8::String::ExternalAsciiStringResource {
11873 class UC16VectorResource : public v8::String::ExternalStringResource {
11917 v8::HandleScope scope;
11925 Local<String> lhs(v8::Utils::ToLocal(
11927 Local<String> rhs(v8::Utils::ToLocal(
11941 MorphAString(*v8::Utils::OpenHandle(*lhs), &ascii_resource, &uc16_resource);
11942 MorphAString(*v8::Utils::OpenHandle(*rhs), &ascii_resource, &uc16_resource);
11980 v8::HandleScope scope;
11998 v8::Local<v8::String> source = v8::String::NewExternal(&uc16_resource);
11999 v8::Script::Compile(source);
12040 v8::Locker::StartPreemption(1);
12043 v8::Unlocker unlock;
12046 v8::Locker::StopPreemption();
12072 v8::Locker lock;
12089 v8::HandleScope scope;
12120 v8::Locker lock;
12121 v8::V8::Initialize();
12122 v8::HandleScope scope;
12143 v8::HandleScope scope;
12144 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
12146 v8::Handle<v8::Object> global = context->Global();
12147 v8::Handle<v8::Object> global_proto =
12148 v8::Handle<v8::Object>::Cast(global->Get(v8_str("__proto__")));
12149 global_proto->Set(v8_str("x"), v8::Integer::New(0), v8::ReadOnly);
12150 global_proto->Set(v8_str("y"), v8::Integer::New(0), v8::ReadOnly);
12152 v8::Handle<v8::Value> res =
12156 CHECK_EQ(v8::Integer::New(42), res);
12159 CHECK_EQ(v8::Integer::New(42), res);
12166 static v8::Handle<v8::Value> ForceSetGetter(v8::Local<v8::String> name,
12167 const v8::AccessorInfo& info) {
12170 return v8::Handle<v8::Value>();
12172 return v8::Int32::New(3);
12176 static void ForceSetSetter(v8::Local<v8::String> name,
12177 v8::Local<v8::Value> value,
12178 const v8::AccessorInfo& info) {
12182 static v8::Handle<v8::Value> ForceSetInterceptSetter(
12183 v8::Local<v8::String> name,
12184 v8::Local<v8::Value> value,
12185 const v8::AccessorInfo& info) {
12187 return v8::Undefined();
12195 v8::HandleScope scope;
12196 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
12197 v8::Handle<v8::String> access_property = v8::String::New("a");
12200 v8::Handle<v8::Object> global = context->Global();
12203 v8::Handle<v8::String> simple_property = v8::String::New("p");
12204 global->Set(simple_property, v8::Int32::New(4), v8::ReadOnly);
12207 global->Set(simple_property, v8::Int32::New(5));
12210 global->ForceSet(simple_property, v8::Int32::New(6));
12219 global->Set(access_property, v8::Int32::New(7));
12225 global->ForceSet(access_property, v8::Int32::New(8));
12236 v8::HandleScope scope;
12237 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
12240 v8::Handle<v8::Object> global = context->Global();
12242 v8::Handle<v8::String> some_property = v8::String::New("a");
12248 global->Set(some_property, v8::Int32::New(7));
12261 global->ForceSet(some_property, v8::Int32::New(8));
12272 CHECK_EQ(3, global->Get(v8::String::New("b"))->Int32Value());
12279 v8::HandleScope scope;
12280 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
12282 v8::Handle<v8::Object> global = context->Global();
12285 v8::Handle<v8::String> simple_property = v8::String::New("p");
12286 global->Set(simple_property, v8::Int32::New(4), v8
12301 static v8::Handle<v8::Boolean> ForceDeleteDeleter(
12302 v8::Local<v8::String> name,
12303 const v8::AccessorInfo& info) {
12306 return v8::Handle<v8::Boolean>();
12308 return v8::True();
12317 v8::HandleScope scope;
12318 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
12321 v8::Handle<v8::Object> global = context->Global();
12323 v8::Handle<v8::String> some_property = v8::String::New("a");
12324 global->Set(some_property, v8::Integer::New(42), v8::DontDelete);
12349 v8::HandleScope scope;
12368 v8::Persistent<Context> calling_context0;
12369 v8::Persistent<Context> calling_context1;
12370 v8::Persistent<Context> calling_context2;
12376 static v8::Handle<Value> GetCallingContextCallback(const v8::Arguments& args) {
12381 return v8::Integer::New(42);
12386 v8::HandleScope scope;
12400 Local<v8::FunctionTemplate> callback_templ =
12401 v8::FunctionTemplate::New(GetCallingContextCallback);
12439 v8::HandleScope scope;
12443 v8::Handle<v8::Value> result = CompileRun("var x; x");
12453 // See http://code.google.com/p/v8/issues/detail?id=398
12455 v8::HandleScope scope;
12457 v8::Handle<v8::Object> obj = v8::Object::New();
12458 v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New();
12459 v8::Handle<v8::String> foo_string = v8::String::New("foo");
12461 v8::Handle<v8::Object> obj_clone = obj->Clone();
12462 obj_clone->Set(foo_string, v8::String::New("Hello"));
12469 v8::HandleScope scope;
12486 v8::HandleScope scope;
12493 v8::kExternalPixelArray,
12507 v8::Handle<v8::Object> obj = v8::Object::New();
12508 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj);
12513 obj->Set(v8_str("field"), v8::Int32::New(1503));
12515 v8::Handle<v8::Value> result = CompileRun("pixels.field");
12674 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
12680 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
12681 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value());
12875 v8::HandleScope scope;
12879 v8::Handle<v8::Object> obj = v8::Object::New();
12889 static v8::Handle<Value> NotHandledIndexedPropertyGetter(
12893 return v8::Handle<Value>();
12897 static v8::Handle<Value> NotHandledIndexedPropertySetter(
12902 return v8::Handle<Value>();
12907 v8::HandleScope scope;
12914 v8::kExternalPixelArray,
12919 v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
12922 v8::Handle<v8::Object> obj = templ->NewInstance();
12925 v8::Handle<v8::Value> result = CompileRun("pixels[1]");
12939 static int ExternalArrayElementSize(v8::ExternalArrayType array_type) {
12941 case v8::kExternalByteArray:
12942 case v8::kExternalUnsignedByteArray:
12943 case v8::kExternalPixelArray:
12946 case v8::kExternalShortArray:
12947 case v8::kExternalUnsignedShortArray:
12950 case v8::kExternalIntArray:
12951 case v8::kExternalUnsignedIntArray:
12952 case v8::kExternalFloatArray:
12955 case v8::kExternalDoubleArray:
12968 static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
12971 v8::HandleScope scope;
12993 v8::Handle<v8::Object> obj = v8::Object::New();
12994 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj);
13001 obj->Set(v8_str("field"), v8::Int32::New(1503));
13003 v8::Handle<v8::Value> result = CompileRun("ext_array.field");
13140 if (array_type == v8::kExternalDoubleArray ||
13141 array_type == v8::kExternalFloatArray) {
13158 if (array_type != v8::kExternalFloatArray &&
13159 array_type != v8::kExternalDoubleArray) {
13181 (array_type == v8::kExternalPixelArray) ? 255 : 0;
13208 (array_type == v8::kExternalUnsignedByteArray ||
13209 array_type == v8::kExternalUnsignedShortArray ||
13210 array_type == v8::kExternalUnsignedIntArray);
13211 bool is_pixel_data = array_type == v8::kExternalPixelArray;
13279 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
13285 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
13286 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value());
13301 v8::Handle<v8::Object> large_obj = v8::Object::New();
13374 v8::Handle<v8::Object> obj2 = v8::Object::New();
13375 obj2->Set(v8_str("ee_test_field"), v8::Int32::New(256));
13376 obj2->Set(v8_str(""), v8::Int32::New(1503));
13388 v8::Handle<v8::Object> obj2 = v8::Object::New();
13389 obj2->Set(v8_str("ee_test_field_2"), v8::Int32::New(256));
13394 obj2->Set(v8_str(""), v8::Int32::New(1503));
13402 v8::Handle<v8::Object> obj2 = v8::Object::New();
13403 obj2->Set(v8_str("ee_test_field_2"), v8::Int32::New(256));
13416 v8::Handle<v8::Object> obj2 = v8::Object::New();
13418 obj2->Set(v8_str("ee_test_field3"), v8::Int32::New(256));
13427 v8::Handle<v8::Object> obj3 = v8::Object::New();
13428 obj3->Set(v8_str("ee_test_field3"), v8::Int32::New(256));
13439 v8::Handle<v8::Object> obj3 = v8::Object::New();
13440 obj3->Set(v8_str("ee_test_field4"), v8::Int32::New(256));
13447 v8::Handle<v8::Object> obj2 = v8::Object::New();
13448 obj2->Set(v8_str("ee_test_field4"), v8::Int32::New(256));
13460 v8::kExternalByteArray,
13468 v8::kExternalUnsignedByteArray,
13476 v8::kExternalPixelArray,
13484 v8::kExternalShortArray,
13492 v8::kExternalUnsignedShortArray,
13500 v8::kExternalIntArray,
13508 v8::kExternalUnsignedIntArray,
13516 v8::kExternalFloatArray,
13524 v8::kExternalDoubleArray,
13541 void ExternalArrayInfoTestHelper(v8::ExternalArrayType array_type) {
13542 v8::HandleScope scope;
13547 v8::Handle<v8::Object> obj = v8::Object::New();
13560 ExternalArrayInfoTestHelper(v8::kExternalByteArray);
13561 ExternalArrayInfoTestHelper(v8::kExternalUnsignedByteArray);
13562 ExternalArrayInfoTestHelper(v8::kExternalShortArray);
13563 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray);
13564 ExternalArrayInfoTestHelper(v8::kExternalIntArray);
13565 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray);
13566 ExternalArrayInfoTestHelper(v8::kExternalFloatArray);
13567 ExternalArrayInfoTestHelper(v8::kExternalDoubleArray);
13568 ExternalArrayInfoTestHelper(v8::kExternalPixelArray);
13573 v8::HandleScope scope;
13576 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source));
13577 v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source));
13578 c1->Global()->Set(v8::String::New("foo"), v8::Integer::New(100));
13582 c2->Global()->Set(v8::String::New("foo"), v8::Integer::New(101));
13589 v8::HandleScope scope;
13591 v8::TryCatch try_catch;
13593 v8::Handle<v8::String> src = v8::String::New(source);
13594 v8::Handle<v8::String> origin = v8::String::New("stack-trace-test");
13595 v8::Script::New(src, origin)->Run();
13597 v8::String::Utf8Value stack(try_catch.StackTrace());
13606 v8::Handle<v8::StackFrame> frame) {
13607 v8::HandleScope scope;
13608 v8::String::Utf8Value func_name(frame->GetFunctionName());
13609 v8::String::Utf8Value script_name(frame->GetScriptName());
13624 v8::Handle<Value> AnalyzeStackInNativeCode(const v8::Arguments& args) {
13625 v8::HandleScope scope;
13634 v8::Handle<v8::StackTrace> stackTrace =
13635 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kOverview);
13650 v8::Handle<v8::StackTrace> stackTrace =
13651 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed);
13672 return v8::Undefined();
13680 v8::HandleScope scope;
13681 v8::Handle<v8::String> origin = v8::String::New("capture-stack-trace-test");
13684 v8::FunctionTemplate::New(AnalyzeStackInNativeCode));
13698 v8::Handle<v8::String> overview_src = v8::String::New(overview_source);
13699 v8::Handle<Value> overview_result(
13700 v8::Script::New(overview_src, origin)->Run());
13713 v8::Handle<v8::String> detailed_src = v8::String::New(detailed_source);
13715 v8::Handle<v8::Integer> line_offset = v8::Integer::New(3);
13716 v8::Handle<v8::Integer> column_offset = v8::Integer::New(5);
13717 v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset);
13718 v8::Handle<v8::Script> detailed_script(
13719 v8::Script::New(detailed_src, &detailed_origin));
13720 v8::Handle<Value> detailed_result(detailed_script->Run());
13727 v8::Handle<v8::Message> message,
13728 v8::Handle<Value>) {
13729 v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
13739 v8::HandleScope scope;
13741 v8::V8::AddMessageListener(StackTraceForUncaughtExceptionListener);
13742 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true);
13751 v8::Local<v8::Object> global = env->Global();
13755 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false);
13756 v8::V8::RemoveMessageListeners(StackTraceForUncaughtExceptionListener);
13761 v8::HandleScope scope;
13763 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true,
13765 v8::StackTrace::kDetailed);
13776 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false);
13780 static void RethrowStackTraceHandler(v8::Handle<v8::Message> message,
13781 v8::Handle<v8::Value> data) {
13783 v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
13797 v8::HandleScope scope;
13816 v8::V8::AddMessageListener(RethrowStackTraceHandler);
13817 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true);
13819 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false);
13820 v8::V8::RemoveMessageListeners(RethrowStackTraceHandler);
13824 static void RethrowPrimitiveStackTraceHandler(v8::Handle<v8::Message> message,
13825 v8::Handle<v8::Value> data) {
13826 v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
13839 v8::HandleScope scope;
13852 v8::V8::AddMessageListener(RethrowPrimitiveStackTraceHandler);
13853 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true);
13855 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false);
13856 v8::V8::RemoveMessageListeners(RethrowPrimitiveStackTraceHandler);
13860 static void RethrowExistingStackTraceHandler(v8::Handle<v8::Message> message,
13861 v8::Handle<v8::Value> data) {
13863 v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
13873 v8::HandleScope scope;
13878 v8::V8::AddMessageListener(RethrowExistingStackTraceHandler);
13879 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true);
13881 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false);
13882 v8::V8::RemoveMessageListeners(RethrowExistingStackTraceHandler);
13886 static void RethrowBogusErrorStackTraceHandler(v8::Handle<v8::Message> message,
13887 v8::Handle<v8::Value> data) {
13889 v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
13898 v8::HandleScope scope;
13903 v8::V8::AddMessageListener(RethrowBogusErrorStackTraceHandler);
13904 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true);
13906 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false);
13907 v8::V8::RemoveMessageListeners(RethrowBogusErrorStackTraceHandler);
13911 v8::Handle<Value> AnalyzeStackOfEvalWithSourceURL(const v8::Arguments& args) {
13912 v8::HandleScope scope;
13913 v8::Handle<v8::StackTrace> stackTrace =
13914 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed);
13916 v8::Handle<v8::String> url = v8_str("eval_url");
13918 v8::Handle<v8::String> name =
13923 return v8::Undefined();
13928 v8::HandleScope scope;
13931 v8::FunctionTemplate::New(AnalyzeStackOfEvalWithSourceURL));
13954 v8::HandleScope scope;
13965 finshed_idle_work = v8::V8::IdleNotification();
13974 v8::HandleScope scope;
13985 bool no_idle_work = v8::V8::IdleNotification(10);
13987 v8::V8::IdleNotification(10);
13998 v8::HandleScope scope;
14009 bool no_idle_work = v8::V8::IdleNotification(900);
14011 finshed_idle_work = v8::V8::IdleNotification(900);
14021 static v8::Handle<Value> GetStackLimitCallback(const v8::Arguments& args) {
14024 return v8::Undefined();
14047 v8::ResourceConstraints constraints;
14049 CHECK(v8::SetResourceConstraints(&constraints));
14052 v8::HandleScope scope;
14054 Local<v8::FunctionTemplate> fun_templ =
14055 v8::FunctionTemplate::New(GetStackLimitCallback);
14067 v8::Locker locker;
14072 v8::ResourceConstraints constraints;
14074 CHECK(v8::SetResourceConstraints(&constraints));
14077 v8::HandleScope scope;
14079 Local<v8::FunctionTemplate> fun_templ =
14080 v8::FunctionTemplate::New(GetStackLimitCallback);
14088 v8::Locker locker;
14095 v8::HandleScope scope;
14097 v8::HeapStatistics heap_statistics;
14100 v8::V8::GetHeapStatistics(&heap_statistics);
14106 class VisitorImpl : public v8::ExternalResourceVisitor {
14114 virtual void VisitExternalString(v8::Handle<v8::String> string) {
14119 v8::String::ExternalStringResource* resource =
14137 v8::String::ExternalStringResource* resource1_;
14138 v8::String::ExternalStringResource* resource2_;
14144 v8::HandleScope scope;
14149 v8::Local<v8::String> string1 = v8::String::NewExternal(resource1);
14151 v8::Local<v8::String> string2 = v8::String::NewExternal(resource2);
14158 v8::V8::VisitExternalResources(&visitor);
14193 v8::HandleScope scope;
14195 v8::TryCatch try_catch;
14238 v8::Handle<v8::Value> number = v8::Number::New(test_value);
14256 v8::Handle<v8::Value> date = v8::Date::New(test_value);
14276 static v8::Handle<Value> SpaghettiIncident(const v8::Arguments& args) {
14277 v8::HandleScope scope;
14278 v8::TryCatch tc;
14279 v8::Handle<v8::String> str(args[0]->ToString());
14283 return v8::Undefined();
14290 v8::HandleScope scope;
14293 v8::String::New("s"),
14294 v8::FunctionTemplate::New(SpaghettiIncident)->GetFunction());
14295 v8::TryCatch try_catch;
14310 v8::String::Utf8Value value(try_catch.Exception());
14316 v8::V8::Initialize();
14318 v8::HandleScope scope;
14319 v8::Persistent<Context> context;
14320 v8::Persistent<Context> other_context;
14332 v8::HandleScope scope;
14335 Local<v8::String> obj = v8::String::New("");
14356 v8::HandleScope scope;
14378 v8::HandleScope scope;
14381 v8::TryCatch try_catch;
14384 v8::Handle<v8::Message> message = try_catch.Message();
14405 v8::HandleScope scope;
14407 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
14408 v8::Handle<v8::String> script = v8::String::New(
14410 v8::Script::Compile(script, &origin)->Run();
14411 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
14412 env->Global()->Get(v8::String::New("f")));
14413 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
14414 env->Global()->Get(v8::String::New("g")));
14416 v8::ScriptOrigin script_origin_f = f->GetScriptOrigin();
14417 CHECK_EQ("test", *v8::String::AsciiValue(script_origin_f.ResourceName()));
14420 v8::ScriptOrigin script_origin_g = g->GetScriptOrigin();
14421 CHECK_EQ("test", *v8::String::AsciiValue(script_origin_g.ResourceName()));
14426 v8::HandleScope scope;
14428 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
14429 v8::Handle<v8::String> script = v8::String::New(
14431 v8::Script::Compile(script, &origin)->Run();
14432 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
14433 env->Global()->Get(v8::String::New("f")));
14434 CHECK_EQ("foo.bar.baz", *v8::String::AsciiValue(f->GetInferredName()));
14438 v8::HandleScope scope;
14440 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
14441 v8::Handle<v8::String> script = v8::String::New(
14443 v8::Script::Compile(script, &origin)->Run();
14444 v8::Local<v8::Function> f = v8::Local<v8::Function>::Cast(
14445 env->Global()->Get(v8::String::New("f")));
14446 v8::Local<v8::Function> g = v8::Local<v8::Function>::Cast(
14447 env->Global()->Get(v8::String::New("g")));
14454 v8::HandleScope scope;
14456 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"),
14457 v8::Integer::New(3), v8::Integer::New(2));
14458 v8::Handle<v8::String> script = v8::String::New(
14460 v8::Script::Compile(script, &origin)->Run();
14461 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
14462 env->Global()->Get(v8::String::New("foo")));
14463 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast(
14464 env->Global()->Get(v8::String::New("bar")));
14471 v8::HandleScope scope;
14473 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"),
14474 v8::Integer::New(3), v8::Integer::New(2));
14475 v8::Handle<v8::String> scriptSource = v8::String::New(
14477 v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin));
14479 v8::Local<v8::Function> foo = v8::Local<v8::Function>::Cast(
14480 env->Global()->Get(v8::String::New("foo")));
14481 v8::Local<v8::Function> bar = v8::Local<v8::Function>::Cast(
14482 env->Global()->Get(v8::String::New("bar")));
14488 static v8::Handle<Value> GetterWhichReturns42(Local<String> name,
14502 v8::HandleScope scope;
14519 v8::Local<v8::Script> script;
14520 script = v8::Script::Compile(v8_str("new C1();"));
14522 v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run());
14527 script = v8::Script::Compile(v8_str("new C2();"));
14529 v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run());
14536 static v8::Handle<Value> NamedPropertyGetterWhichReturns42(
14542 static v8::Handle<Value> NamedPropertySetterWhichSetsYOnThisTo23(
14547 return v8::Handle<Value>();
14552 v8::HandleScope scope;
14568 v8::Local<v8::Script> script;
14569 script = v8::Script::Compile(v8_str("new C1();"));
14571 v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run());
14576 script = v8::Script::Compile(v8_str("new C2();"));
14578 v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run());
14591 v8::HandleScope scope;
14593 v8::Local<v8::Script> script;
14596 v8::Local<v8::Object> prototype = v8::Object::New();
14603 script = v8::Script::Compile(v8_str("new C1();"));
14607 v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run());
14622 script = v8::Script::Compile(v8_str("new C1();"));
14624 v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run());
14635 void PrologueCallback(v8::GCType, v8::GCCallbackFlags) {
14639 void EpilogueCallback(v8::GCType, v8::GCCallbackFlags) {
14643 void PrologueCallbackSecond(v8::GCType, v8::GCCallbackFlags) {
14647 void EpilogueCallbackSecond(v8::GCType, v8::GCCallbackFlags) {
14654 v8::V8::AddGCPrologueCallback(PrologueCallback);
14655 v8::V8::AddGCEpilogueCallback(EpilogueCallback);
14661 v8::V8::AddGCPrologueCallback(PrologueCallbackSecond);
14662 v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond);
14668 v8::V8::RemoveGCPrologueCallback(PrologueCallback);
14669 v8::V8::RemoveGCEpilogueCallback(EpilogueCallback);
14675 v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond);
14676 v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond);
14687 v8::HandleScope scope;
14714 v8::HandleScope scope;
14736 v8::HandleScope scope;
14761 v8::HandleScope scope;
14786 v8::HandleScope scope;
14804 v8::HandleScope scope;
14817 i::Handle<i::String> string = v8::Utils::OpenHandle(String::Cast(*result));
14891 void FailedAccessCheckCallbackGC(Local<v8::Object> target,
14892 v8::AccessType type,
14893 Local<v8::Value> data) {
14902 v8::V8::Initialize();
14903 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC);
14905 v8::HandleScope scope;
14909 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
14912 v8::Handle<v8::Value>(),
14918 v8::Handle<v8::Object> global0 = context0->Global();
14932 v8::Handle<v8::Value> result = CompileRun("other.x = new Object()");
14972 v8::V8::SetFailedAccessCheckCallbackFunction(NULL);
14976 CHECK(v8::Isolate::GetCurrent() != NULL);
14977 v8::Isolate* isolate = v8::Isolate::GetCurrent();
14983 v8::Isolate* current_isolate = v8::Isolate::GetCurrent();
14984 v8::Isolate* isolate = v8::Isolate::New();
14988 CHECK(current_isolate == v8::Isolate::GetCurrent());
14990 v8::V8::SetFatalErrorHandler(StoringErrorCallback);
14998 v8::HandleScope scope;
15000 v8::Isolate* current_isolate = v8::Isolate::GetCurrent();
15009 CHECK_EQ(v8::Isolate::GetCurrent(), current_isolate);
15011 // that has no isolate and attempts to execute V8 APIs.
15016 v8::V8::SetFatalErrorHandler(StoringErrorCallback);
15018 // Run some V8 code to trigger default isolate to become 'current'.
15019 v8
15021 ExpectString("'run some V8'", "run some V8");
15023 v8::Isolate* isolate = v8::Isolate::GetCurrent();
15033 v8::HandleScope scope;
15037 v8::Isolate* isolate = v8::Isolate::New();
15042 v8::HandleScope scope_new;
15064 v8::V8::SetFatalErrorHandler(StoringErrorCallback);
15075 v8::Isolate* isolate = v8::Isolate::New();
15078 v8::HandleScope scope;
15082 v8::V8::SetFatalErrorHandler(StoringErrorCallback);
15092 v8::Isolate* isolate1 = v8::Isolate::New();
15094 v8::Persistent<v8::Context> context1 = v8::Context::New();
15097 v8::Context::Scope cscope(context1);
15098 v8::HandleScope scope;
15105 v8::Isolate* isolate2 = v8::Isolate::New();
15106 v8::Persistent<v8::Context> context2;
15109 v8::Isolate::Scope iscope(isolate2);
15110 context2 = v8::Context::New();
15111 v8::Context::Scope cscope(context2);
15112 v8::HandleScope scope;
15120 v8::Context::Scope cscope(context1);
15121 v8::HandleScope scope;
15129 v8::Persistent<v8::Context> context_default = v8::Context::New();
15132 v8::Context::Scope cscope(context_default);
15133 v8::HandleScope scope;
15151 v8::Isolate::Scope iscope(isolate2);
15152 v8::Context::Scope cscope(context2);
15153 v8::HandleScope scope;
15158 v8::Context::Scope cscope(context1);
15159 v8::HandleScope scope;
15164 v8::Isolate::Scope iscope(isolate2);
15171 v8::V8::SetFatalErrorHandler(StoringErrorCallback);
15184 v8::Context::Scope cscope(context_default);
15185 v8::HandleScope scope;
15190 static int CalcFibonacci(v8::Isolate* isolate, int limit) {
15191 v8::Isolate::Scope isolate_scope(isolate);
15192 v8::HandleScope scope;
15205 class IsolateThread : public v8::internal::Thread {
15207 IsolateThread(v8::Isolate* isolate, int fib_limit)
15220 v8::Isolate* isolate_;
15226 v8::Isolate* isolate1 = v8::Isolate::New();
15227 v8::Isolate* isolate2 = v8::Isolate::New();
15236 int result1 = CalcFibonacci(v8::Isolate::GetCurrent(), 21);
15237 int result2 = CalcFibonacci(v8::Isolate::GetCurrent(), 12);
15254 v8::Isolate* isolate = v8::Isolate::New();
15255 Persistent<v8::Context> context;
15257 v8::Isolate::Scope isolate_scope(isolate);
15258 v8::HandleScope handle_scope;
15259 context = v8::Context::New();
15260 v8::Context::Scope context_scope(context);
15266 v8::Isolate::Scope isolate_scope(isolate);
15267 v8::HandleScope handle_scope;
15268 context = v8::Context::New();
15269 v8::Context::Scope context_scope(context);
15276 class InitDefaultIsolateThread : public v8::internal::Thread {
15295 v8::V8::IgnoreOutOfMemoryException();
15300 v8::ResourceConstraints constraints;
15303 v8::SetResourceConstraints(&constraints);
15308 v8::V8::SetFatalErrorHandler(NULL);
15312 v8::V8::SetCounterFunction(NULL);
15316 v8::V8::SetCreateHistogramFunction(NULL);
15320 v8::V8::SetAddHistogramSampleFunction(NULL);
15372 v8::HandleScope scope;
15381 v8::HandleScope scope;
15395 v8::HandleScope scope;
15404 v8::HandleScope scope;
15418 v8::HandleScope scope;
15427 v8::HandleScope scope;
15442 v8::HandleScope scope;
15453 v8::HandleScope scope;
15481 v8::HandleScope scope;
15509 v8::HandleScope scope;
15511 context->Global()->Set(v8_str("cell"), v8_str("value"), v8::DontDelete);
15532 v8::HandleScope scope;
15535 v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone);
15538 CHECK_EQ(v8::RegExp::kNone, re->GetFlags());
15540 re = v8::RegExp::New(v8_str("bar"),
15541 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase |
15542 v8::RegExp::kGlobal));
15545 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kGlobal,
15548 re = v8::RegExp::New(v8_str("baz"),
15549 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase |
15550 v8::RegExp::kMultiline));
15553 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline,
15556 re = CompileRun("/quux/").As<v8::RegExp>();
15559 CHECK_EQ(v8::RegExp::kNone, re->GetFlags());
15561 re = CompileRun("/quux/gm").As<v8::RegExp>();
15564 CHECK_EQ(v8::RegExp::kGlobal | v8::RegExp::kMultiline,
15571 re = v8::RegExp::New(v8_str("foobar"), v8::RegExp::kNone);
15574 CHECK_EQ(v8::RegExp::kNone, re->GetFlags());
15576 re = v8::RegExp::New(v8_str("foobarbaz"),
15577 static_cast<v8::RegExp::Flags>(v8::RegExp::kIgnoreCase |
15578 v8::RegExp::kMultiline));
15581 CHECK_EQ(v8::RegExp::kIgnoreCase | v8::RegExp::kMultiline,
15588 re->Set(v8_str("property"), v8
15589 v8::Handle<v8::Value> value(CompileRun("re.property"));
15592 v8::TryCatch try_catch;
15593 re = v8::RegExp::New(v8_str("foo["), v8::RegExp::kNone);
15602 v8::HandleScope handleScope;
15605 v8::Handle<v8::Object> globalProxy = localContext->Global();
15606 v8::Handle<Value> global = globalProxy->GetPrototype();
15620 static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property,
15621 const v8::AccessorInfo& info ) {
15626 static v8::Handle<v8::Array> Enumerator(const v8::AccessorInfo& info) {
15627 v8::Handle<v8::Array> result = v8::Array::New();
15634 v8::HandleScope handle_scope;
15636 v8::Context::Scope context_scope(context.local());
15638 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
15641 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
15649 v8::HandleScope scope;
15651 v8::Handle<v8::Object> proxy = context->Global();
15652 v8::Handle<v8::Function> define_property =
15664 static void InstallContextId(v8::Handle<Context> context, int id) {
15667 Set(v8_str("context_id"), v8::Integer::New(id));
15671 static void CheckContextId(v8::Handle<Object> object, int expected) {
15685 Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New();
15784 return Handle<v8::Integer>();
15795 Handle<v8::Integer> HasOwnPropertyIndexedPropertyQuery(
15797 if (index == 42) return v8_num(1).As<v8::Integer>();
15798 return Handle<v8::Integer>();
15802 Handle<v8::Integer> HasOwnPropertyNamedPropertyQuery(
15804 if (property->Equals(v8_str("foo"))) return v8_num(1).As<v8::Integer>();
15805 return Handle<v8::Integer>();
15809 Handle<v8::Integer> HasOwnPropertyNamedPropertyQuery2(
15811 if (property->Equals(v8_str("bar"))) return v8_num(1).As<v8::Integer>();
15812 return Handle<v8::Integer>();
15823 v8::HandleScope scope;
15937 v8::HandleScope scope;
15955 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationAllowed);
15960 V8::SetAllowCodeGenerationFromStringsCallback(&CodeGenerationDisallowed);
15966 static v8::Handle<Value> NonObjectThis(const v8::Arguments& args) {
15967 return v8::Undefined();
15972 v8::HandleScope scope;
15974 Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis);
15984 v8::HandleScope scope;
15988 Local<v8::Object> obj = templ->NewInstance();
15990 obj->Set(v8_str("1"), v8_str("DONT_CHANGE"), v8::ReadOnly);
15993 obj->Set(v8_num(2), v8_str("DONT_CHANGE"), v8::ReadOnly);
15998 obj->Set(v8_str("2000000000"), v8_str("DONT_CHANGE"), v8::ReadOnly);
16005 v8::HandleScope scope;
16008 { v8::HandleScope temp_scope;
16029 static bool BlockProtoNamedSecurityTestCallback(Local<v8::Object> global,
16031 v8::AccessType type,
16034 if (type == v8::ACCESS_GET &&
16051 Local<ObjectTemplate> no_proto_template = v8::ObjectTemplate::New();
16058 Local<FunctionTemplate> hidden_proto_template = v8::FunctionTemplate::New();
16062 v8::FunctionTemplate::New();
16069 Persistent<Context> context = v8::Context::New();
16139 v8::HandleScope scope;
16180 Persistent<Context> foreign_context = v8::Context::New();
16301 v8::HandleScope scope;
16303 v8::Handle<v8::FunctionTemplate> recursive_runtime =
16304 v8::FunctionTemplate::New(RecursiveCall);
16308 v8::V8::AddCallCompletedCallback(CallCompletedCallback1);
16309 v8::V8::AddCallCompletedCallback(CallCompletedCallback1);
16310 v8::V8::AddCallCompletedCallback(CallCompletedCallback2);
16313 v8::Script::Compile(v8::String::New("recursion(0)"));
16319 v8::V8::RemoveCallCompletedCallback(CallCompletedCallback1);
16327 v8::Handle<Value> args[] = { v8_num(0) };
16334 v8::HandleScope scope;
16340 v8::HandleScope scope;
16346 v8::HandleScope scope;
16348 v8::V8::AddCallCompletedCallback(CallCompletedCallbackNoException);
16354 v8::HandleScope scope;
16356 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException);
16367 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) {
16369 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) {
16371 } else if (strcmp(name, "c:V8.MegamorphicStubCacheUpdates") == 0) {
16393 V8::SetCounterFunction(LookupCounter);
16403 v8::HandleScope scope;