OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 LocalContext env; | 415 LocalContext env; |
416 env->Global()->Set(v8_str("obj"), obj->NewInstance()); | 416 env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
417 Script::Compile(String::New( | 417 Script::Compile(String::New( |
418 "function foo() {" | 418 "function foo() {" |
419 " return obj.xxx;" | 419 " return obj.xxx;" |
420 "}" | 420 "}" |
421 "for (var i = 0; i < 100; i++) {" | 421 "for (var i = 0; i < 100; i++) {" |
422 " foo();" | 422 " foo();" |
423 "}"))->Run(); | 423 "}"))->Run(); |
424 } | 424 } |
| 425 |
| 426 |
| 427 static v8::Handle<Value> AllocateHandles(Local<String> name, |
| 428 const AccessorInfo& info) { |
| 429 for (int i = 0; i < i::kHandleBlockSize + 1; i++) { |
| 430 v8::Local<v8::Value>::New(name); |
| 431 } |
| 432 return v8::Integer::New(100); |
| 433 } |
| 434 |
| 435 |
| 436 THREADED_TEST(HandleScopeSegment) { |
| 437 // Check that we can return values past popping of handle scope |
| 438 // segments. |
| 439 v8::HandleScope scope; |
| 440 v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
| 441 obj->SetAccessor(v8_str("xxx"), AllocateHandles); |
| 442 LocalContext env; |
| 443 env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
| 444 v8::Handle<v8::Value> result = Script::Compile(String::New( |
| 445 "var result;" |
| 446 "for (var i = 0; i < 4; i++)" |
| 447 " result = obj.xxx;" |
| 448 "result;"))->Run(); |
| 449 CHECK_EQ(100, result->Int32Value()); |
| 450 } |
OLD | NEW |