• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #if V8_TARGET_ARCH_ARM64
6 
7 #include "src/codegen/arm64/decoder-arm64.h"
8 #include "src/common/globals.h"
9 #include "src/utils/utils.h"
10 
11 namespace v8 {
12 namespace internal {
13 
AppendVisitor(DecoderVisitor * new_visitor)14 void DispatchingDecoderVisitor::AppendVisitor(DecoderVisitor* new_visitor) {
15   visitors_.remove(new_visitor);
16   visitors_.push_back(new_visitor);
17 }
18 
PrependVisitor(DecoderVisitor * new_visitor)19 void DispatchingDecoderVisitor::PrependVisitor(DecoderVisitor* new_visitor) {
20   visitors_.remove(new_visitor);
21   visitors_.push_front(new_visitor);
22 }
23 
InsertVisitorBefore(DecoderVisitor * new_visitor,DecoderVisitor * registered_visitor)24 void DispatchingDecoderVisitor::InsertVisitorBefore(
25     DecoderVisitor* new_visitor, DecoderVisitor* registered_visitor) {
26   visitors_.remove(new_visitor);
27   std::list<DecoderVisitor*>::iterator it;
28   for (it = visitors_.begin(); it != visitors_.end(); it++) {
29     if (*it == registered_visitor) {
30       visitors_.insert(it, new_visitor);
31       return;
32     }
33   }
34   // We reached the end of the list. The last element must be
35   // registered_visitor.
36   DCHECK(*it == registered_visitor);
37   visitors_.insert(it, new_visitor);
38 }
39 
InsertVisitorAfter(DecoderVisitor * new_visitor,DecoderVisitor * registered_visitor)40 void DispatchingDecoderVisitor::InsertVisitorAfter(
41     DecoderVisitor* new_visitor, DecoderVisitor* registered_visitor) {
42   visitors_.remove(new_visitor);
43   std::list<DecoderVisitor*>::iterator it;
44   for (it = visitors_.begin(); it != visitors_.end(); it++) {
45     if (*it == registered_visitor) {
46       it++;
47       visitors_.insert(it, new_visitor);
48       return;
49     }
50   }
51   // We reached the end of the list. The last element must be
52   // registered_visitor.
53   DCHECK(*it == registered_visitor);
54   visitors_.push_back(new_visitor);
55 }
56 
RemoveVisitor(DecoderVisitor * visitor)57 void DispatchingDecoderVisitor::RemoveVisitor(DecoderVisitor* visitor) {
58   visitors_.remove(visitor);
59 }
60 
61 #define DEFINE_VISITOR_CALLERS(A)                                \
62   void DispatchingDecoderVisitor::Visit##A(Instruction* instr) { \
63     if (!(instr->Mask(A##FMask) == A##Fixed)) {                  \
64       DCHECK(instr->Mask(A##FMask) == A##Fixed);                 \
65     }                                                            \
66     std::list<DecoderVisitor*>::iterator it;                     \
67     for (it = visitors_.begin(); it != visitors_.end(); it++) {  \
68       (*it)->Visit##A(instr);                                    \
69     }                                                            \
70   }
71 VISITOR_LIST(DEFINE_VISITOR_CALLERS)
72 #undef DEFINE_VISITOR_CALLERS
73 
74 }  // namespace internal
75 }  // namespace v8
76 
77 #endif  // V8_TARGET_ARCH_ARM64
78