| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 25 matching lines...) Expand all Loading... |
| 36 using v8::internal::Thread; | 36 using v8::internal::Thread; |
| 37 | 37 |
| 38 static const int kValueCount = 128; | 38 static const int kValueCount = 128; |
| 39 | 39 |
| 40 static Thread::LocalStorageKey keys[kValueCount]; | 40 static Thread::LocalStorageKey keys[kValueCount]; |
| 41 | 41 |
| 42 static void* GetValue(int num) { | 42 static void* GetValue(int num) { |
| 43 return reinterpret_cast<void*>(static_cast<intptr_t>(num + 1)); | 43 return reinterpret_cast<void*>(static_cast<intptr_t>(num + 1)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 |
| 46 static void DoTest() { | 47 static void DoTest() { |
| 47 for (int i = 0; i < kValueCount; i++) { | 48 for (int i = 0; i < kValueCount; i++) { |
| 48 CHECK(!Thread::HasThreadLocal(keys[i])); | 49 CHECK(!Thread::HasThreadLocal(keys[i])); |
| 49 } | 50 } |
| 50 for (int i = 0; i < kValueCount; i++) { | 51 for (int i = 0; i < kValueCount; i++) { |
| 51 Thread::SetThreadLocal(keys[i], GetValue(i)); | 52 Thread::SetThreadLocal(keys[i], GetValue(i)); |
| 52 } | 53 } |
| 53 for (int i = 0; i < kValueCount; i++) { | 54 for (int i = 0; i < kValueCount; i++) { |
| 54 CHECK(Thread::HasThreadLocal(keys[i])); | 55 CHECK(Thread::HasThreadLocal(keys[i])); |
| 55 } | 56 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 73 | 74 |
| 74 class TestThread : public Thread { | 75 class TestThread : public Thread { |
| 75 public: | 76 public: |
| 76 TestThread() : Thread("TestThread") {} | 77 TestThread() : Thread("TestThread") {} |
| 77 | 78 |
| 78 virtual void Run() { | 79 virtual void Run() { |
| 79 DoTest(); | 80 DoTest(); |
| 80 } | 81 } |
| 81 }; | 82 }; |
| 82 | 83 |
| 84 |
| 83 TEST(FastTLS) { | 85 TEST(FastTLS) { |
| 84 for (int i = 0; i < kValueCount; i++) { | 86 for (int i = 0; i < kValueCount; i++) { |
| 85 keys[i] = Thread::CreateThreadLocalKey(); | 87 keys[i] = Thread::CreateThreadLocalKey(); |
| 86 } | 88 } |
| 87 DoTest(); | 89 DoTest(); |
| 88 TestThread thread; | 90 TestThread thread; |
| 89 thread.Start(); | 91 thread.Start(); |
| 90 thread.Join(); | 92 thread.Join(); |
| 91 } | 93 } |
| OLD | NEW |