Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: src/hydrogen-infer-types.cc

Issue 148503002: A64: Synchronize with r15545. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-infer-types.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "marking-thread.h" 28 #include "hydrogen-infer-types.h"
29
30 #include "v8.h"
31
32 #include "isolate.h"
33 #include "v8threads.h"
34 29
35 namespace v8 { 30 namespace v8 {
36 namespace internal { 31 namespace internal {
37 32
38 MarkingThread::MarkingThread(Isolate* isolate) 33 void HInferTypesPhase::InferTypes(int from_inclusive, int to_inclusive) {
39 : Thread("MarkingThread"), 34 for (int i = from_inclusive; i <= to_inclusive; ++i) {
40 isolate_(isolate), 35 HBasicBlock* block = graph()->blocks()->at(i);
41 heap_(isolate->heap()),
42 start_marking_semaphore_(OS::CreateSemaphore(0)),
43 end_marking_semaphore_(OS::CreateSemaphore(0)),
44 stop_semaphore_(OS::CreateSemaphore(0)) {
45 NoBarrier_Store(&stop_thread_, static_cast<AtomicWord>(false));
46 id_ = NoBarrier_AtomicIncrement(&id_counter_, 1);
47 }
48 36
49 37 const ZoneList<HPhi*>* phis = block->phis();
50 Atomic32 MarkingThread::id_counter_ = -1; 38 for (int j = 0; j < phis->length(); j++) {
51 39 phis->at(j)->UpdateInferredType();
52
53 void MarkingThread::Run() {
54 Isolate::SetIsolateThreadLocals(isolate_, NULL);
55 DisallowHeapAllocation no_allocation;
56 DisallowHandleAllocation no_handles;
57 DisallowHandleDereference no_deref;
58
59 while (true) {
60 start_marking_semaphore_->Wait();
61
62 if (Acquire_Load(&stop_thread_)) {
63 stop_semaphore_->Signal();
64 return;
65 } 40 }
66 41
67 end_marking_semaphore_->Signal(); 42 for (HInstructionIterator it(block); !it.Done(); it.Advance()) {
43 it.Current()->UpdateInferredType();
44 }
45
46 if (block->IsLoopHeader()) {
47 HBasicBlock* last_back_edge =
48 block->loop_information()->GetLastBackEdge();
49 InferTypes(i + 1, last_back_edge->block_id());
50 // Skip all blocks already processed by the recursive call.
51 i = last_back_edge->block_id();
52 // Update phis of the loop header now after the whole loop body is
53 // guaranteed to be processed.
54 for (int j = 0; j < block->phis()->length(); ++j) {
55 HPhi* phi = block->phis()->at(j);
56 worklist_.Add(phi, zone());
57 in_worklist_.Add(phi->id());
58 }
59 while (!worklist_.is_empty()) {
60 HValue* current = worklist_.RemoveLast();
61 in_worklist_.Remove(current->id());
62 if (current->UpdateInferredType()) {
63 for (HUseIterator it(current->uses()); !it.Done(); it.Advance()) {
64 HValue* use = it.value();
65 if (!in_worklist_.Contains(use->id())) {
66 in_worklist_.Add(use->id());
67 worklist_.Add(use, zone());
68 }
69 }
70 }
71 }
72 ASSERT(in_worklist_.IsEmpty());
73 }
68 } 74 }
69 } 75 }
70 76
71
72 void MarkingThread::Stop() {
73 Release_Store(&stop_thread_, static_cast<AtomicWord>(true));
74 start_marking_semaphore_->Signal();
75 stop_semaphore_->Wait();
76 }
77
78
79 void MarkingThread::StartMarking() {
80 start_marking_semaphore_->Signal();
81 }
82
83
84 void MarkingThread::WaitForMarkingThread() {
85 end_marking_semaphore_->Wait();
86 }
87
88 } } // namespace v8::internal 77 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-infer-types.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698