OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 String SerializedScriptValue::toWireString() const { | 138 String SerializedScriptValue::toWireString() const { |
139 if (!m_dataString.isNull()) | 139 if (!m_dataString.isNull()) |
140 return m_dataString; | 140 return m_dataString; |
141 | 141 |
142 // Add the padding '\0', but don't put it in |m_dataBuffer|. | 142 // Add the padding '\0', but don't put it in |m_dataBuffer|. |
143 // This requires direct use of uninitialized strings, though. | 143 // This requires direct use of uninitialized strings, though. |
144 UChar* destination; | 144 UChar* destination; |
145 size_t stringSizeBytes = (m_dataBufferSize + 1) & ~1; | 145 size_t stringSizeBytes = (m_dataBufferSize + 1) & ~1; |
146 String wireString = | 146 String wireString = |
147 String::createUninitialized(stringSizeBytes / 2, destination); | 147 String::createUninitialized(stringSizeBytes / 2, destination); |
| 148 LOG(ERROR) << "wire string at " << ((void*)wireString.impl()) << ", buffer at
" << ((void*)destination); |
148 memcpy(destination, m_dataBuffer.get(), m_dataBufferSize); | 149 memcpy(destination, m_dataBuffer.get(), m_dataBufferSize); |
149 if (stringSizeBytes > m_dataBufferSize) | 150 if (stringSizeBytes > m_dataBufferSize) |
150 reinterpret_cast<char*>(destination)[stringSizeBytes - 1] = '\0'; | 151 reinterpret_cast<char*>(destination)[stringSizeBytes - 1] = '\0'; |
151 return wireString; | 152 return wireString; |
152 } | 153 } |
153 | 154 |
154 // Convert serialized string to big endian wire data. | 155 // Convert serialized string to big endian wire data. |
155 void SerializedScriptValue::toWireBytes(Vector<char>& result) const { | 156 void SerializedScriptValue::toWireBytes(Vector<char>& result) const { |
156 DCHECK(result.isEmpty()); | 157 DCHECK(result.isEmpty()); |
157 | 158 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() { | 456 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() { |
456 if (m_externallyAllocatedMemory) | 457 if (m_externallyAllocatedMemory) |
457 return; | 458 return; |
458 | 459 |
459 m_externallyAllocatedMemory = static_cast<intptr_t>(dataLengthInBytes()); | 460 m_externallyAllocatedMemory = static_cast<intptr_t>(dataLengthInBytes()); |
460 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( | 461 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( |
461 m_externallyAllocatedMemory); | 462 m_externallyAllocatedMemory); |
462 } | 463 } |
463 | 464 |
464 } // namespace blink | 465 } // namespace blink |
OLD | NEW |