OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 | 110 |
111 | 111 |
112 static int x_register = 0; | 112 static int x_register = 0; |
113 static v8::Handle<v8::Object> x_receiver; | 113 static v8::Handle<v8::Object> x_receiver; |
114 static v8::Handle<v8::Object> x_holder; | 114 static v8::Handle<v8::Object> x_holder; |
115 | 115 |
116 | 116 |
117 static v8::Handle<Value> XGetter(Local<String> name, const AccessorInfo& info) { | 117 static v8::Handle<Value> XGetter(Local<String> name, const AccessorInfo& info) { |
118 ApiTestFuzzer::Fuzz(); | 118 ApiTestFuzzer::Fuzz(); |
| 119 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 120 CHECK_EQ(isolate, info.GetIsolate()); |
119 CHECK_EQ(x_receiver, info.This()); | 121 CHECK_EQ(x_receiver, info.This()); |
120 CHECK_EQ(x_holder, info.Holder()); | 122 CHECK_EQ(x_holder, info.Holder()); |
121 return v8_num(x_register); | 123 return v8_num(x_register); |
122 } | 124 } |
123 | 125 |
124 | 126 |
125 static void XSetter(Local<String> name, | 127 static void XSetter(Local<String> name, |
126 Local<Value> value, | 128 Local<Value> value, |
127 const AccessorInfo& info) { | 129 const AccessorInfo& info) { |
| 130 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 131 CHECK_EQ(isolate, info.GetIsolate()); |
128 CHECK_EQ(x_holder, info.This()); | 132 CHECK_EQ(x_holder, info.This()); |
129 CHECK_EQ(x_holder, info.Holder()); | 133 CHECK_EQ(x_holder, info.Holder()); |
130 x_register = value->Int32Value(); | 134 x_register = value->Int32Value(); |
131 } | 135 } |
132 | 136 |
133 | 137 |
134 THREADED_TEST(AccessorIC) { | 138 THREADED_TEST(AccessorIC) { |
135 v8::HandleScope scope; | 139 v8::HandleScope scope; |
136 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 140 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
137 obj->SetAccessor(v8_str("x"), XGetter, XSetter); | 141 obj->SetAccessor(v8_str("x"), XGetter, XSetter); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 " obj.one;" | 233 " obj.one;" |
230 " obj.many;" | 234 " obj.many;" |
231 "}"); | 235 "}"); |
232 } | 236 } |
233 int count_after = i::HandleScope::NumberOfHandles(); | 237 int count_after = i::HandleScope::NumberOfHandles(); |
234 CHECK_EQ(count_before, count_after); | 238 CHECK_EQ(count_before, count_after); |
235 } | 239 } |
236 | 240 |
237 static v8::Handle<Value> CheckAccessorArgsCorrect(Local<String> name, | 241 static v8::Handle<Value> CheckAccessorArgsCorrect(Local<String> name, |
238 const AccessorInfo& info) { | 242 const AccessorInfo& info) { |
| 243 CHECK(info.GetIsolate() == v8::Isolate::GetCurrent()); |
239 CHECK(info.This() == info.Holder()); | 244 CHECK(info.This() == info.Holder()); |
240 CHECK(info.Data()->Equals(v8::String::New("data"))); | 245 CHECK(info.Data()->Equals(v8::String::New("data"))); |
241 ApiTestFuzzer::Fuzz(); | 246 ApiTestFuzzer::Fuzz(); |
| 247 CHECK(info.GetIsolate() == v8::Isolate::GetCurrent()); |
242 CHECK(info.This() == info.Holder()); | 248 CHECK(info.This() == info.Holder()); |
243 CHECK(info.Data()->Equals(v8::String::New("data"))); | 249 CHECK(info.Data()->Equals(v8::String::New("data"))); |
244 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 250 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 251 CHECK(info.GetIsolate() == v8::Isolate::GetCurrent()); |
245 CHECK(info.This() == info.Holder()); | 252 CHECK(info.This() == info.Holder()); |
246 CHECK(info.Data()->Equals(v8::String::New("data"))); | 253 CHECK(info.Data()->Equals(v8::String::New("data"))); |
247 return v8::Integer::New(17); | 254 return v8::Integer::New(17); |
248 } | 255 } |
249 | 256 |
250 THREADED_TEST(DirectCall) { | 257 THREADED_TEST(DirectCall) { |
251 v8::HandleScope scope; | 258 v8::HandleScope scope; |
252 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); | 259 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
253 obj->SetAccessor(v8_str("xxx"), | 260 obj->SetAccessor(v8_str("xxx"), |
254 CheckAccessorArgsCorrect, | 261 CheckAccessorArgsCorrect, |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 obj->SetAccessor(v8_str("xxx"), AllocateHandles); | 446 obj->SetAccessor(v8_str("xxx"), AllocateHandles); |
440 LocalContext env; | 447 LocalContext env; |
441 env->Global()->Set(v8_str("obj"), obj->NewInstance()); | 448 env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
442 v8::Handle<v8::Value> result = Script::Compile(String::New( | 449 v8::Handle<v8::Value> result = Script::Compile(String::New( |
443 "var result;" | 450 "var result;" |
444 "for (var i = 0; i < 4; i++)" | 451 "for (var i = 0; i < 4; i++)" |
445 " result = obj.xxx;" | 452 " result = obj.xxx;" |
446 "result;"))->Run(); | 453 "result;"))->Run(); |
447 CHECK_EQ(100, result->Int32Value()); | 454 CHECK_EQ(100, result->Int32Value()); |
448 } | 455 } |
OLD | NEW |