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

Side by Side Diff: Source/bindings/dart/DartScriptWrappable.h

Issue 611833004: [multivm] Re-split fields for V8 and Dart wrappers. (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/multivm
Patch Set: Created 6 years, 2 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 | « Source/bindings/core/v8/V8ScriptWrappable.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 19 matching lines...) Expand all
30 30
31 #ifndef DartScriptWrappable_h 31 #ifndef DartScriptWrappable_h
32 #define DartScriptWrappable_h 32 #define DartScriptWrappable_h
33 33
34 #include "bindings/common/ScriptWrappable.h" 34 #include "bindings/common/ScriptWrappable.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 class DartWrapperInfo { 38 class DartWrapperInfo {
39 public: 39 public:
40 ScriptWrappable::TaggedPointer v8WrapperOrEmpty;
41 void* domData; 40 void* domData;
42 void* wrapper; 41 void* wrapper;
43 }; 42 };
44 43
45 class DartMultiWrapperInfo { 44 class DartMultiWrapperInfo {
46 public: 45 public:
47 ScriptWrappable::TaggedPointer v8WrapperOrEmpty;
48 Vector<void*> domDatas; 46 Vector<void*> domDatas;
49 Vector<void*> wrappers; 47 Vector<void*> wrappers;
50 }; 48 };
51 49
52 inline ScriptWrappable::TaggedPointer ScriptWrappable::getV8WrapperOrEmpty() con st
53 {
54 if (LIKELY(m_wrapper.isV8WrapperOrEmpty())) {
55 return m_wrapper;
56 }
57 if (UNLIKELY(m_wrapper.isDartWrapperInfo())) {
58 return m_wrapper.dartWrapperInfo()->v8WrapperOrEmpty;
59 }
60 ASSERT(m_wrapper.isDartMultiWrapperInfo());
61 return m_wrapper.dartMultiWrapperInfo()->v8WrapperOrEmpty;
62 }
63
64 void ScriptWrappable::setDartWrapper(void* domData, void* wrapper) 50 void ScriptWrappable::setDartWrapper(void* domData, void* wrapper)
65 { 51 {
66 ASSERT(domData); 52 ASSERT(domData);
67 if (LIKELY(m_wrapper.isEmpty() || m_wrapper.isV8Wrapper())) { 53 if (LIKELY(m_dartWrapperInfo.isEmpty())) {
68 DartWrapperInfo* wrapperInfo = new DartWrapperInfo; 54 DartWrapperInfo* wrapperInfo = new DartWrapperInfo;
69 wrapperInfo->v8WrapperOrEmpty = m_wrapper;
70 wrapperInfo->domData = domData; 55 wrapperInfo->domData = domData;
71 wrapperInfo->wrapper = wrapper; 56 wrapperInfo->wrapper = wrapper;
72 m_wrapper = TaggedPointer(wrapperInfo); 57 m_dartWrapperInfo = TaggedPointer(wrapperInfo);
73 } else if (m_wrapper.isDartWrapperInfo()) { 58 } else if (m_dartWrapperInfo.isDartWrapperInfo()) {
74 DartWrapperInfo* wrapperInfo = m_wrapper.dartWrapperInfo(); 59 DartWrapperInfo* wrapperInfo = m_dartWrapperInfo.dartWrapperInfo();
75 if (wrapperInfo->domData == domData) { 60 if (wrapperInfo->domData == domData) {
76 // Replace the current wrapper (e.g., upgrading a custom element). 61 // Replace the current wrapper (e.g., upgrading a custom element).
77 wrapperInfo->wrapper = wrapper; 62 wrapperInfo->wrapper = wrapper;
78 } else { 63 } else {
79 // Inflate to a multiwrapper, unimplemented. 64 // Inflate to a multiwrapper, unimplemented.
80 ASSERT_NOT_REACHED(); 65 ASSERT_NOT_REACHED();
81 } 66 }
82 } else { 67 } else {
83 ASSERT(m_wrapper.isDartMultiWrapperInfo()); 68 ASSERT(m_dartWrapperInfo.isDartMultiWrapperInfo());
84 // Replace or append wrapper, unimplemented. 69 // Replace or append wrapper, unimplemented.
85 ASSERT_NOT_REACHED(); 70 ASSERT_NOT_REACHED();
86 } 71 }
87 } 72 }
88 73
89 void* ScriptWrappable::getDartWrapper(void* domData) const 74 void* ScriptWrappable::getDartWrapper(void* domData) const
90 { 75 {
91 ASSERT(domData); 76 ASSERT(domData);
92 if (m_wrapper.isDartWrapperInfo()) { 77 if (m_dartWrapperInfo.isDartWrapperInfo()) {
93 DartWrapperInfo* wrapperInfo = m_wrapper.dartWrapperInfo(); 78 DartWrapperInfo* wrapperInfo = m_dartWrapperInfo.dartWrapperInfo();
94 if (wrapperInfo->domData == domData) { 79 if (wrapperInfo->domData == domData) {
95 return wrapperInfo->wrapper; 80 return wrapperInfo->wrapper;
96 } 81 }
97 return 0; 82 return 0;
98 } 83 }
99 if (m_wrapper.isDartMultiWrapperInfo()) { 84 if (m_dartWrapperInfo.isDartMultiWrapperInfo()) {
100 DartMultiWrapperInfo* wrapperInfo = m_wrapper.dartMultiWrapperInfo(); 85 DartMultiWrapperInfo* wrapperInfo = m_dartWrapperInfo.dartMultiWrapperIn fo();
101 for (unsigned i = 0; i < wrapperInfo->domDatas.size(); ++i) { 86 for (unsigned i = 0; i < wrapperInfo->domDatas.size(); ++i) {
102 if (wrapperInfo->domDatas.at(i) == domData) { 87 if (wrapperInfo->domDatas.at(i) == domData) {
103 return wrapperInfo->wrappers.at(i); 88 return wrapperInfo->wrappers.at(i);
104 } 89 }
105 } 90 }
106 return 0; 91 return 0;
107 } 92 }
108 ASSERT(m_wrapper.isEmpty() || m_wrapper.isV8Wrapper()); 93 ASSERT(m_wrapper.isEmpty());
109 return 0; 94 return 0;
110 } 95 }
111 96
112 void ScriptWrappable::clearDartWrapper(void* wrapper) 97 void ScriptWrappable::clearDartWrapper(void* wrapper)
113 { 98 {
114 if (LIKELY(m_wrapper.isDartWrapperInfo())) { 99 if (LIKELY(m_dartWrapperInfo.isDartWrapperInfo())) {
115 DartWrapperInfo* wrapperInfo = m_wrapper.dartWrapperInfo(); 100 DartWrapperInfo* wrapperInfo = m_dartWrapperInfo.dartWrapperInfo();
116 // ASSERT(Dart_IdentityEquals(wrapper, wrapperInfo->wrapper)); 101 // ASSERT(Dart_IdentityEquals(wrapper, wrapperInfo->wrapper));
117 m_wrapper = wrapperInfo->v8WrapperOrEmpty; 102 m_dartWrapperInfo = TaggedPointer();
118 delete wrapperInfo; 103 delete wrapperInfo;
119 } else if (m_wrapper.isDartMultiWrapperInfo()) { 104 } else if (m_dartWrapperInfo.isDartMultiWrapperInfo()) {
120 // Remove or deflate, unimplemented. 105 // Remove or deflate, unimplemented.
121 ASSERT_NOT_REACHED(); 106 ASSERT_NOT_REACHED();
122 } else { 107 } else {
123 // Already clear. 108 // Already clear.
124 ASSERT_NOT_REACHED(); 109 ASSERT_NOT_REACHED();
125 } 110 }
126 } 111 }
127 112
128 } // namespace blink 113 } // namespace blink
129 114
130 #endif // DartScriptWrappable_h 115 #endif // DartScriptWrappable_h
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8ScriptWrappable.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698