OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 4272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4283 static inline bool EndsWithSurrogate(uint8_t state) { | 4283 static inline bool EndsWithSurrogate(uint8_t state) { |
4284 return state & kEndsWithLeadingSurrogate; | 4284 return state & kEndsWithLeadingSurrogate; |
4285 } | 4285 } |
4286 | 4286 |
4287 static inline bool StartsWithSurrogate(uint8_t state) { | 4287 static inline bool StartsWithSurrogate(uint8_t state) { |
4288 return state & kStartsWithTrailingSurrogate; | 4288 return state & kStartsWithTrailingSurrogate; |
4289 } | 4289 } |
4290 | 4290 |
4291 class Visitor { | 4291 class Visitor { |
4292 public: | 4292 public: |
4293 inline explicit Visitor() | 4293 Visitor() : utf8_length_(0), state_(kInitialState) {} |
4294 : utf8_length_(0), | |
4295 state_(kInitialState) {} | |
4296 | 4294 |
4297 void VisitOneByteString(const uint8_t* chars, int length) { | 4295 void VisitOneByteString(const uint8_t* chars, int length) { |
4298 int utf8_length = 0; | 4296 int utf8_length = 0; |
4299 // Add in length 1 for each non-ASCII character. | 4297 // Add in length 1 for each non-ASCII character. |
4300 for (int i = 0; i < length; i++) { | 4298 for (int i = 0; i < length; i++) { |
4301 utf8_length += *chars++ >> 7; | 4299 utf8_length += *chars++ >> 7; |
4302 } | 4300 } |
4303 // Add in length 1 for each character. | 4301 // Add in length 1 for each character. |
4304 utf8_length_ = utf8_length + length; | 4302 utf8_length_ = utf8_length + length; |
4305 state_ = kInitialState; | 4303 state_ = kInitialState; |
(...skipping 3332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7638 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7636 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7639 Address callback_address = | 7637 Address callback_address = |
7640 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7638 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7641 VMState<EXTERNAL> state(isolate); | 7639 VMState<EXTERNAL> state(isolate); |
7642 ExternalCallbackScope call_scope(isolate, callback_address); | 7640 ExternalCallbackScope call_scope(isolate, callback_address); |
7643 callback(info); | 7641 callback(info); |
7644 } | 7642 } |
7645 | 7643 |
7646 | 7644 |
7647 } } // namespace v8::internal | 7645 } } // namespace v8::internal |
OLD | NEW |