Chromium Code Reviews| 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 store->ReadNameAndContentPair(source); | 75 store->ReadNameAndContentPair(source); |
| 76 | 76 |
| 77 store->debugger_count_ = debugger_count; | 77 store->debugger_count_ = debugger_count; |
| 78 return store; | 78 return store; |
| 79 } | 79 } |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 NativesStore() : debugger_count_(0) {} | 82 NativesStore() : debugger_count_(0) {} |
| 83 | 83 |
| 84 Vector<const char> NameFromId(const byte* id, int id_length) { | 84 Vector<const char> NameFromId(const byte* id, int id_length) { |
| 85 Vector<char> name(Vector<char>::New(id_length + 11)); | 85 const char native[] = "native "; |
|
Sven Panne
2014/12/18 10:32:32
Probably not a big deal here, but note that GCC ac
| |
| 86 SimpleStringBuilder builder(name.start(), name.length()); | 86 const char extension[] = ".js"; |
| 87 builder.AddString("native "); | 87 Vector<char> name(Vector<char>::New(id_length + sizeof(native) - 1 + |
| 88 builder.AddSubstring(reinterpret_cast<const char*>(id), id_length); | 88 sizeof(extension) - 1)); |
| 89 builder.AddString(".js"); | 89 memcpy(name.start(), native, sizeof(native) - 1); |
| 90 builder.Finalize(); | 90 memcpy(name.start() + sizeof(native) - 1, id, id_length); |
| 91 // SimpleStringBuilder wants zero-byte; the caller does not. | 91 memcpy(name.start() + sizeof(native) - 1 + id_length, extension, |
| 92 DCHECK(name[name.length() - 1] == '\0'); | 92 sizeof(extension) - 1); |
| 93 name.Truncate(name.length() - 1); | |
| 94 return Vector<const char>::cast(name); | 93 return Vector<const char>::cast(name); |
| 95 } | 94 } |
| 96 | 95 |
| 97 bool ReadNameAndContentPair(SnapshotByteSource* bytes) { | 96 bool ReadNameAndContentPair(SnapshotByteSource* bytes) { |
| 98 const byte* id; | 97 const byte* id; |
| 99 int id_length; | 98 int id_length; |
| 100 const byte* source; | 99 const byte* source; |
| 101 int source_length; | 100 int source_length; |
| 102 bool success = bytes->GetBlob(&id, &id_length) && | 101 bool success = bytes->GetBlob(&id, &id_length) && |
| 103 bytes->GetBlob(&source, &source_length); | 102 bytes->GetBlob(&source, &source_length); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 } | 194 } |
| 196 | 195 |
| 197 | 196 |
| 198 // The compiler can't 'see' all uses of the static methods and hence | 197 // The compiler can't 'see' all uses of the static methods and hence |
| 199 // my choice to elide them. This we'll explicitly instantiate these. | 198 // my choice to elide them. This we'll explicitly instantiate these. |
| 200 template class NativesCollection<CORE>; | 199 template class NativesCollection<CORE>; |
| 201 template class NativesCollection<EXPERIMENTAL>; | 200 template class NativesCollection<EXPERIMENTAL>; |
| 202 | 201 |
| 203 } // namespace v8::internal | 202 } // namespace v8::internal |
| 204 } // namespace v8 | 203 } // namespace v8 |
| OLD | NEW |