| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 5211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5222 | 5222 |
| 5223 v8::Persistent<v8::Object> object_a; | 5223 v8::Persistent<v8::Object> object_a; |
| 5224 | 5224 |
| 5225 { | 5225 { |
| 5226 v8::HandleScope handle_scope; | 5226 v8::HandleScope handle_scope; |
| 5227 object_a = v8::Persistent<v8::Object>::New(v8::Object::New()); | 5227 object_a = v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 5228 } | 5228 } |
| 5229 | 5229 |
| 5230 bool object_a_disposed = false; | 5230 bool object_a_disposed = false; |
| 5231 object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag); | 5231 object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag); |
| 5232 CHECK(!object_a.IsIndependent()); |
| 5232 object_a.MarkIndependent(); | 5233 object_a.MarkIndependent(); |
| 5234 CHECK(object_a.IsIndependent()); |
| 5233 HEAP->PerformScavenge(); | 5235 HEAP->PerformScavenge(); |
| 5234 CHECK(object_a_disposed); | 5236 CHECK(object_a_disposed); |
| 5235 } | 5237 } |
| 5236 | 5238 |
| 5237 | 5239 |
| 5238 static void InvokeScavenge() { | 5240 static void InvokeScavenge() { |
| 5239 HEAP->PerformScavenge(); | 5241 HEAP->PerformScavenge(); |
| 5240 } | 5242 } |
| 5241 | 5243 |
| 5242 | 5244 |
| (...skipping 10927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16170 " try {" | 16172 " try {" |
| 16171 " return readCell();" | 16173 " return readCell();" |
| 16172 " } catch(e) {" | 16174 " } catch(e) {" |
| 16173 " return e.toString();" | 16175 " return e.toString();" |
| 16174 " }" | 16176 " }" |
| 16175 "})()", | 16177 "})()", |
| 16176 "ReferenceError: cell is not defined"); | 16178 "ReferenceError: cell is not defined"); |
| 16177 } | 16179 } |
| 16178 | 16180 |
| 16179 | 16181 |
| 16182 TEST(PersistentHandleVisitor) { |
| 16183 v8::HandleScope scope; |
| 16184 LocalContext context; |
| 16185 v8::Persistent<v8::Object> object = |
| 16186 v8::Persistent<v8::Object>::New(v8::Object::New()); |
| 16187 CHECK_EQ(0, object.WrapperClassId()); |
| 16188 object.SetWrapperClassId(42); |
| 16189 CHECK_EQ(42, object.WrapperClassId()); |
| 16190 |
| 16191 class Visitor : public v8::PersistentHandleVisitor { |
| 16192 public: |
| 16193 explicit Visitor(v8::Persistent<v8::Object> object) |
| 16194 : counter_(0), object_(object) { } |
| 16195 |
| 16196 virtual void VisitPersistentHandle(Persistent<Value> value, |
| 16197 uint16_t class_id) { |
| 16198 if (class_id == 42) { |
| 16199 CHECK(value->IsObject()); |
| 16200 v8::Persistent<v8::Object> visited = |
| 16201 v8::Persistent<v8::Object>::Cast(value); |
| 16202 CHECK_EQ(42, visited.WrapperClassId()); |
| 16203 CHECK_EQ(object_, visited); |
| 16204 ++counter_; |
| 16205 } |
| 16206 } |
| 16207 |
| 16208 int counter_; |
| 16209 v8::Persistent<v8::Object> object_; |
| 16210 } visitor(object); |
| 16211 |
| 16212 v8::V8::VisitHandlesWithClassIds(&visitor); |
| 16213 CHECK_EQ(1, visitor.counter_); |
| 16214 |
| 16215 object.Dispose(); |
| 16216 } |
| 16217 |
| 16218 |
| 16180 TEST(RegExp) { | 16219 TEST(RegExp) { |
| 16181 v8::HandleScope scope; | 16220 v8::HandleScope scope; |
| 16182 LocalContext context; | 16221 LocalContext context; |
| 16183 | 16222 |
| 16184 v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone); | 16223 v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone); |
| 16185 CHECK(re->IsRegExp()); | 16224 CHECK(re->IsRegExp()); |
| 16186 CHECK(re->GetSource()->Equals(v8_str("foo"))); | 16225 CHECK(re->GetSource()->Equals(v8_str("foo"))); |
| 16187 CHECK_EQ(v8::RegExp::kNone, re->GetFlags()); | 16226 CHECK_EQ(v8::RegExp::kNone, re->GetFlags()); |
| 16188 | 16227 |
| 16189 re = v8::RegExp::New(v8_str("bar"), | 16228 re = v8::RegExp::New(v8_str("bar"), |
| (...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17623 | 17662 |
| 17624 i::Semaphore* sem_; | 17663 i::Semaphore* sem_; |
| 17625 volatile int sem_value_; | 17664 volatile int sem_value_; |
| 17626 }; | 17665 }; |
| 17627 | 17666 |
| 17628 | 17667 |
| 17629 THREADED_TEST(SemaphoreInterruption) { | 17668 THREADED_TEST(SemaphoreInterruption) { |
| 17630 ThreadInterruptTest().RunTest(); | 17669 ThreadInterruptTest().RunTest(); |
| 17631 } | 17670 } |
| 17632 #endif // WIN32 | 17671 #endif // WIN32 |
| OLD | NEW |