| 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/inspector/V8DebuggerScript.h" | 5 #include "src/inspector/V8DebuggerScript.h" |
| 6 | 6 |
| 7 #include "src/inspector/ProtocolPlatform.h" | 7 #include "src/inspector/ProtocolPlatform.h" |
| 8 #include "src/inspector/StringUtil.h" | 8 #include "src/inspector/StringUtil.h" |
| 9 | 9 |
| 10 namespace v8_inspector { | 10 namespace v8_inspector { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 static uint64_t prime[] = {0x3FB75161, 0xAB1F4E4F, 0x82675BC5, 0xCD924D35, | 27 static uint64_t prime[] = {0x3FB75161, 0xAB1F4E4F, 0x82675BC5, 0xCD924D35, |
| 28 0x81ABE279}; | 28 0x81ABE279}; |
| 29 static uint64_t random[] = {0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, | 29 static uint64_t random[] = {0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, |
| 30 0xC3D2E1F0}; | 30 0xC3D2E1F0}; |
| 31 static uint32_t randomOdd[] = {0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA11D, | 31 static uint32_t randomOdd[] = {0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA11D, |
| 32 0x8F462907}; | 32 0x8F462907}; |
| 33 | 33 |
| 34 uint64_t hashes[] = {0, 0, 0, 0, 0}; | 34 uint64_t hashes[] = {0, 0, 0, 0, 0}; |
| 35 uint64_t zi[] = {1, 1, 1, 1, 1}; | 35 uint64_t zi[] = {1, 1, 1, 1, 1}; |
| 36 | 36 |
| 37 const size_t hashesSize = V8_INSPECTOR_ARRAY_LENGTH(hashes); | 37 const size_t hashesSize = arraysize(hashes); |
| 38 | 38 |
| 39 size_t current = 0; | 39 size_t current = 0; |
| 40 const uint32_t* data = nullptr; | 40 const uint32_t* data = nullptr; |
| 41 size_t sizeInBytes = sizeof(UChar) * str.length(); | 41 size_t sizeInBytes = sizeof(UChar) * str.length(); |
| 42 data = reinterpret_cast<const uint32_t*>(str.characters16()); | 42 data = reinterpret_cast<const uint32_t*>(str.characters16()); |
| 43 for (size_t i = 0; i < sizeInBytes / 4; i += 4) { | 43 for (size_t i = 0; i < sizeInBytes / 4; i += 4) { |
| 44 uint32_t v = data[i]; | 44 uint32_t v = data[i]; |
| 45 uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; | 45 uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; |
| 46 hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; | 46 hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; |
| 47 zi[current] = (zi[current] * random[current]) % prime[current]; | 47 zi[current] = (zi[current] * random[current]) % prime[current]; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 m_sourceMappingURL = sourceMappingURL; | 131 m_sourceMappingURL = sourceMappingURL; |
| 132 } | 132 } |
| 133 | 133 |
| 134 void V8DebuggerScript::setSource(v8::Isolate* isolate, | 134 void V8DebuggerScript::setSource(v8::Isolate* isolate, |
| 135 v8::Local<v8::String> source) { | 135 v8::Local<v8::String> source) { |
| 136 m_source.Reset(isolate, source); | 136 m_source.Reset(isolate, source); |
| 137 m_hash = calculateHash(toProtocolString(source)); | 137 m_hash = calculateHash(toProtocolString(source)); |
| 138 } | 138 } |
| 139 | 139 |
| 140 } // namespace v8_inspector | 140 } // namespace v8_inspector |
| OLD | NEW |