OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/natives.h" | 5 #include "src/natives.h" |
6 | 6 |
7 #include "src/base/logging.h" | 7 #include "src/base/logging.h" |
8 #include "src/list.h" | 8 #include "src/list.h" |
9 #include "src/list-inl.h" | 9 #include "src/list-inl.h" |
10 #include "src/snapshot-source-sink.h" | 10 #include "src/snapshot-source-sink.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 private: | 76 private: |
77 NativesStore() : debugger_count_(0) {} | 77 NativesStore() : debugger_count_(0) {} |
78 | 78 |
79 Vector<const char> NameFromId(const byte* id, int id_length) { | 79 Vector<const char> NameFromId(const byte* id, int id_length) { |
80 Vector<char> name(Vector<char>::New(id_length + 11)); | 80 Vector<char> name(Vector<char>::New(id_length + 11)); |
81 SimpleStringBuilder builder(name.start(), name.length()); | 81 SimpleStringBuilder builder(name.start(), name.length()); |
82 builder.AddString("native "); | 82 builder.AddString("native "); |
83 builder.AddSubstring(reinterpret_cast<const char*>(id), id_length); | 83 builder.AddSubstring(reinterpret_cast<const char*>(id), id_length); |
84 builder.AddString(".js"); | 84 builder.AddString(".js"); |
| 85 builder.Finalize(); |
| 86 // SimpleStringBuilder wants zero-byte; the caller does not. |
| 87 DCHECK(name[name.length() - 1] == '\0'); |
| 88 name.Truncate(name.length() - 1); |
85 return Vector<const char>::cast(name); | 89 return Vector<const char>::cast(name); |
86 } | 90 } |
87 | 91 |
88 bool ReadNameAndContentPair(SnapshotByteSource* bytes) { | 92 bool ReadNameAndContentPair(SnapshotByteSource* bytes) { |
89 const byte* id; | 93 const byte* id; |
90 int id_length; | 94 int id_length; |
91 const byte* source; | 95 const byte* source; |
92 int source_length; | 96 int source_length; |
93 bool success = bytes->GetBlob(&id, &id_length) && | 97 bool success = bytes->GetBlob(&id, &id_length) && |
94 bytes->GetBlob(&source, &source_length); | 98 bytes->GetBlob(&source, &source_length); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 } | 191 } |
188 | 192 |
189 | 193 |
190 // The compiler can't 'see' all uses of the static methods and hence | 194 // The compiler can't 'see' all uses of the static methods and hence |
191 // my chose to elide them. This we'll explicitly instantiate these. | 195 // my chose to elide them. This we'll explicitly instantiate these. |
192 template class NativesCollection<CORE>; | 196 template class NativesCollection<CORE>; |
193 template class NativesCollection<EXPERIMENTAL>; | 197 template class NativesCollection<EXPERIMENTAL>; |
194 | 198 |
195 } // namespace v8::internal | 199 } // namespace v8::internal |
196 } // namespace v8 | 200 } // namespace v8 |
OLD | NEW |