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 3327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7633 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7631 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7634 Address callback_address = | 7632 Address callback_address = |
7635 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7633 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7636 VMState<EXTERNAL> state(isolate); | 7634 VMState<EXTERNAL> state(isolate); |
7637 ExternalCallbackScope call_scope(isolate, callback_address); | 7635 ExternalCallbackScope call_scope(isolate, callback_address); |
7638 callback(info); | 7636 callback(info); |
7639 } | 7637 } |
7640 | 7638 |
7641 | 7639 |
7642 } } // namespace v8::internal | 7640 } } // namespace v8::internal |
OLD | NEW |