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 5540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5551 | 5551 |
5552 void v8::Object::SetAlignedPointerInInternalField(int index, void* value) { | 5552 void v8::Object::SetAlignedPointerInInternalField(int index, void* value) { |
5553 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); | 5553 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); |
5554 const char* location = "v8::Object::SetAlignedPointerInInternalField()"; | 5554 const char* location = "v8::Object::SetAlignedPointerInInternalField()"; |
5555 if (!InternalFieldOK(obj, index, location)) return; | 5555 if (!InternalFieldOK(obj, index, location)) return; |
5556 i::Handle<i::JSObject>::cast(obj) | 5556 i::Handle<i::JSObject>::cast(obj) |
5557 ->SetInternalField(index, EncodeAlignedAsSmi(value, location)); | 5557 ->SetInternalField(index, EncodeAlignedAsSmi(value, location)); |
5558 DCHECK_EQ(value, GetAlignedPointerFromInternalField(index)); | 5558 DCHECK_EQ(value, GetAlignedPointerFromInternalField(index)); |
5559 } | 5559 } |
5560 | 5560 |
| 5561 void v8::Object::SetAlignedPointerInInternalFields(int argc, int indices[], |
| 5562 void* values[]) { |
| 5563 i::Handle<i::JSReceiver> obj = Utils::OpenHandle(this); |
| 5564 const char* location = "v8::Object::SetAlignedPointerInInternalFields()"; |
| 5565 i::DisallowHeapAllocation no_gc; |
| 5566 i::JSObject* object = i::JSObject::cast(*obj); |
| 5567 int nof_internal_fields = jobject->GetInternalFieldCount(); |
| 5568 for (int i = 0; i < argc; i++) { |
| 5569 int index = indices[i]; |
| 5570 if (!Utils::ApiCheck( |
| 5571 index < nof_internal_fields, |
| 5572 location, "Internal field out of bounds") { |
| 5573 return; |
| 5574 } |
| 5575 void* value = values[i]; |
| 5576 object->SetInternalField(index, EncodeAlignedAsSmi(value, location)); |
| 5577 DCHECK_EQ(value, GetAlignedPointerFromInternalField(index)); |
| 5578 } |
| 5579 } |
5561 | 5580 |
5562 static void* ExternalValue(i::Object* obj) { | 5581 static void* ExternalValue(i::Object* obj) { |
5563 // Obscure semantics for undefined, but somehow checked in our unit tests... | 5582 // Obscure semantics for undefined, but somehow checked in our unit tests... |
5564 if (!obj->IsSmi() && | 5583 if (!obj->IsSmi() && |
5565 obj->IsUndefined(i::HeapObject::cast(obj)->GetIsolate())) { | 5584 obj->IsUndefined(i::HeapObject::cast(obj)->GetIsolate())) { |
5566 return NULL; | 5585 return NULL; |
5567 } | 5586 } |
5568 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0); | 5587 i::Object* foreign = i::JSObject::cast(obj)->GetInternalField(0); |
5569 return i::Foreign::cast(foreign)->foreign_address(); | 5588 return i::Foreign::cast(foreign)->foreign_address(); |
5570 } | 5589 } |
(...skipping 3471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9042 Address callback_address = | 9061 Address callback_address = |
9043 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9062 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
9044 VMState<EXTERNAL> state(isolate); | 9063 VMState<EXTERNAL> state(isolate); |
9045 ExternalCallbackScope call_scope(isolate, callback_address); | 9064 ExternalCallbackScope call_scope(isolate, callback_address); |
9046 callback(info); | 9065 callback(info); |
9047 } | 9066 } |
9048 | 9067 |
9049 | 9068 |
9050 } // namespace internal | 9069 } // namespace internal |
9051 } // namespace v8 | 9070 } // namespace v8 |
OLD | NEW |