diff options
Diffstat (limited to 'deps/v8/src/objects.cc')
-rw-r--r-- | deps/v8/src/objects.cc | 157 |
1 files changed, 84 insertions, 73 deletions
diff --git a/deps/v8/src/objects.cc b/deps/v8/src/objects.cc index ea2c202c9e..834589a019 100644 --- a/deps/v8/src/objects.cc +++ b/deps/v8/src/objects.cc @@ -28,6 +28,7 @@ #include "v8.h" #include "api.h" +#include "arguments.h" #include "bootstrapper.h" #include "debug.h" #include "execution.h" @@ -158,14 +159,12 @@ Object* Object::GetPropertyWithCallback(Object* receiver, Object* fun_obj = data->getter(); v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj); HandleScope scope; - Handle<JSObject> self(JSObject::cast(receiver)); - Handle<JSObject> holder_handle(JSObject::cast(holder)); + JSObject* self = JSObject::cast(receiver); + JSObject* holder_handle = JSObject::cast(holder); Handle<String> key(name); - Handle<Object> fun_data(data->data()); - LOG(ApiNamedPropertyAccess("load", *self, name)); - v8::AccessorInfo info(v8::Utils::ToLocal(self), - v8::Utils::ToLocal(fun_data), - v8::Utils::ToLocal(holder_handle)); + LOG(ApiNamedPropertyAccess("load", self, name)); + CustomArguments args(data->data(), self, holder_handle); + v8::AccessorInfo info(args.end()); v8::Handle<v8::Value> result; { // Leaving JavaScript. @@ -1538,11 +1537,9 @@ Object* JSObject::SetPropertyWithInterceptor(String* name, Handle<Object> value_handle(value); Handle<InterceptorInfo> interceptor(GetNamedInterceptor()); if (!interceptor->setter()->IsUndefined()) { - Handle<Object> data_handle(interceptor->data()); LOG(ApiNamedPropertyAccess("interceptor-named-set", this, name)); - v8::AccessorInfo info(v8::Utils::ToLocal(this_handle), - v8::Utils::ToLocal(data_handle), - v8::Utils::ToLocal(this_handle)); + CustomArguments args(interceptor->data(), this, this); + v8::AccessorInfo info(args.end()); v8::NamedPropertySetter setter = v8::ToCData<v8::NamedPropertySetter>(interceptor->setter()); v8::Handle<v8::Value> result; @@ -1605,14 +1602,10 @@ Object* JSObject::SetPropertyWithCallback(Object* structure, Object* call_obj = data->setter(); v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj); if (call_fun == NULL) return value; - Handle<JSObject> self(this); - Handle<JSObject> holder_handle(JSObject::cast(holder)); Handle<String> key(name); - Handle<Object> fun_data(data->data()); LOG(ApiNamedPropertyAccess("store", this, name)); - v8::AccessorInfo info(v8::Utils::ToLocal(self), - v8::Utils::ToLocal(fun_data), - v8::Utils::ToLocal(holder_handle)); + CustomArguments args(data->data(), this, JSObject::cast(holder)); + v8::AccessorInfo info(args.end()); { // Leaving JavaScript. VMState state(EXTERNAL); @@ -2036,10 +2029,8 @@ PropertyAttributes JSObject::GetPropertyAttributeWithInterceptor( Handle<JSObject> receiver_handle(receiver); Handle<JSObject> holder_handle(this); Handle<String> name_handle(name); - Handle<Object> data_handle(interceptor->data()); - v8::AccessorInfo info(v8::Utils::ToLocal(receiver_handle), - v8::Utils::ToLocal(data_handle), - v8::Utils::ToLocal(holder_handle)); + CustomArguments args(interceptor->data(), receiver, this); + v8::AccessorInfo info(args.end()); if (!interceptor->query()->IsUndefined()) { v8::NamedPropertyQuery query = v8::ToCData<v8::NamedPropertyQuery>(interceptor->query()); @@ -2307,11 +2298,9 @@ Object* JSObject::DeletePropertyWithInterceptor(String* name) { if (!interceptor->deleter()->IsUndefined()) { v8::NamedPropertyDeleter deleter = v8::ToCData<v8::NamedPropertyDeleter>(interceptor->deleter()); - Handle<Object> data_handle(interceptor->data()); LOG(ApiNamedPropertyAccess("interceptor-named-delete", *this_handle, name)); - v8::AccessorInfo info(v8::Utils::ToLocal(this_handle), - v8::Utils::ToLocal(data_handle), - v8::Utils::ToLocal(this_handle)); + CustomArguments args(interceptor->data(), this, this); + v8::AccessorInfo info(args.end()); v8::Handle<v8::Boolean> result; { // Leaving JavaScript. @@ -2370,11 +2359,9 @@ Object* JSObject::DeleteElementWithInterceptor(uint32_t index) { v8::IndexedPropertyDeleter deleter = v8::ToCData<v8::IndexedPropertyDeleter>(interceptor->deleter()); Handle<JSObject> this_handle(this); - Handle<Object> data_handle(interceptor->data()); LOG(ApiIndexedPropertyAccess("interceptor-indexed-delete", this, index)); - v8::AccessorInfo info(v8::Utils::ToLocal(this_handle), - v8::Utils::ToLocal(data_handle), - v8::Utils::ToLocal(this_handle)); + CustomArguments args(interceptor->data(), this, this); + v8::AccessorInfo info(args.end()); v8::Handle<v8::Boolean> result; { // Leaving JavaScript. @@ -3971,35 +3958,75 @@ const unibrow::byte* String::ReadBlock(String* input, } -FlatStringReader* FlatStringReader::top_ = NULL; +Relocatable* Relocatable::top_ = NULL; + + +void Relocatable::PostGarbageCollectionProcessing() { + Relocatable* current = top_; + while (current != NULL) { + current->PostGarbageCollection(); + current = current->prev_; + } +} + + +// Reserve space for statics needing saving and restoring. +int Relocatable::ArchiveSpacePerThread() { + return sizeof(top_); +} + + +// Archive statics that are thread local. +char* Relocatable::ArchiveState(char* to) { + *reinterpret_cast<Relocatable**>(to) = top_; + top_ = NULL; + return to + ArchiveSpacePerThread(); +} + + +// Restore statics that are thread local. +char* Relocatable::RestoreState(char* from) { + top_ = *reinterpret_cast<Relocatable**>(from); + return from + ArchiveSpacePerThread(); +} + + +char* Relocatable::Iterate(ObjectVisitor* v, char* thread_storage) { + Relocatable* top = *reinterpret_cast<Relocatable**>(thread_storage); + Iterate(v, top); + return thread_storage + ArchiveSpacePerThread(); +} + + +void Relocatable::Iterate(ObjectVisitor* v) { + Iterate(v, top_); +} + + +void Relocatable::Iterate(ObjectVisitor* v, Relocatable* top) { + Relocatable* current = top; + while (current != NULL) { + current->IterateInstance(v); + current = current->prev_; + } +} FlatStringReader::FlatStringReader(Handle<String> str) : str_(str.location()), - length_(str->length()), - prev_(top_) { - top_ = this; - RefreshState(); + length_(str->length()) { + PostGarbageCollection(); } FlatStringReader::FlatStringReader(Vector<const char> input) - : str_(NULL), + : str_(0), is_ascii_(true), length_(input.length()), - start_(input.start()), - prev_(top_) { - top_ = this; -} + start_(input.start()) { } -FlatStringReader::~FlatStringReader() { - ASSERT_EQ(top_, this); - top_ = prev_; -} - - -void FlatStringReader::RefreshState() { +void FlatStringReader::PostGarbageCollection() { if (str_ == NULL) return; Handle<String> str(str_); ASSERT(str->IsFlat()); @@ -4012,15 +4039,6 @@ void FlatStringReader::RefreshState() { } -void FlatStringReader::PostGarbageCollectionProcessing() { - FlatStringReader* current = top_; - while (current != NULL) { - current->RefreshState(); - current = current->prev_; - } -} - - void StringInputBuffer::Seek(unsigned pos) { Reset(pos, input_); } @@ -5033,15 +5051,16 @@ void Code::CopyFrom(const CodeDesc& desc) { int mode_mask = RelocInfo::kCodeTargetMask | RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | RelocInfo::kApplyMask; + Assembler* origin = desc.origin; // Needed to find target_object on X64. for (RelocIterator it(this, mode_mask); !it.done(); it.next()) { RelocInfo::Mode mode = it.rinfo()->rmode(); if (mode == RelocInfo::EMBEDDED_OBJECT) { - Object** p = reinterpret_cast<Object**>(it.rinfo()->target_object()); + Handle<Object> p = it.rinfo()->target_object_handle(origin); it.rinfo()->set_target_object(*p); } else if (RelocInfo::IsCodeTarget(mode)) { // rewrite code handles in inline cache targets to direct // pointers to the first instruction in the code object - Object** p = reinterpret_cast<Object**>(it.rinfo()->target_object()); + Handle<Object> p = it.rinfo()->target_object_handle(origin); Code* code = Code::cast(*p); it.rinfo()->set_target_address(code->instruction_start()); } else { @@ -5429,10 +5448,8 @@ bool JSObject::HasElementWithInterceptor(JSObject* receiver, uint32_t index) { Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); Handle<JSObject> receiver_handle(receiver); Handle<JSObject> holder_handle(this); - Handle<Object> data_handle(interceptor->data()); - v8::AccessorInfo info(v8::Utils::ToLocal(receiver_handle), - v8::Utils::ToLocal(data_handle), - v8::Utils::ToLocal(holder_handle)); + CustomArguments args(interceptor->data(), receiver, this); + v8::AccessorInfo info(args.end()); if (!interceptor->query()->IsUndefined()) { v8::IndexedPropertyQuery query = v8::ToCData<v8::IndexedPropertyQuery>(interceptor->query()); @@ -5564,11 +5581,9 @@ Object* JSObject::SetElementWithInterceptor(uint32_t index, Object* value) { if (!interceptor->setter()->IsUndefined()) { v8::IndexedPropertySetter setter = v8::ToCData<v8::IndexedPropertySetter>(interceptor->setter()); - Handle<Object> data_handle(interceptor->data()); LOG(ApiIndexedPropertyAccess("interceptor-indexed-set", this, index)); - v8::AccessorInfo info(v8::Utils::ToLocal(this_handle), - v8::Utils::ToLocal(data_handle), - v8::Utils::ToLocal(this_handle)); + CustomArguments args(interceptor->data(), this, this); + v8::AccessorInfo info(args.end()); v8::Handle<v8::Value> result; { // Leaving JavaScript. @@ -5836,13 +5851,11 @@ Object* JSObject::GetElementWithInterceptor(JSObject* receiver, Handle<JSObject> holder_handle(this); if (!interceptor->getter()->IsUndefined()) { - Handle<Object> data_handle(interceptor->data()); v8::IndexedPropertyGetter getter = v8::ToCData<v8::IndexedPropertyGetter>(interceptor->getter()); LOG(ApiIndexedPropertyAccess("interceptor-indexed-get", this, index)); - v8::AccessorInfo info(v8::Utils::ToLocal(this_handle), - v8::Utils::ToLocal(data_handle), - v8::Utils::ToLocal(holder_handle)); + CustomArguments args(interceptor->data(), receiver, this); + v8::AccessorInfo info(args.end()); v8::Handle<v8::Value> result; { // Leaving JavaScript. @@ -6074,15 +6087,13 @@ Object* JSObject::GetPropertyWithInterceptor( Handle<JSObject> receiver_handle(receiver); Handle<JSObject> holder_handle(this); Handle<String> name_handle(name); - Handle<Object> data_handle(interceptor->data()); if (!interceptor->getter()->IsUndefined()) { v8::NamedPropertyGetter getter = v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter()); LOG(ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name)); - v8::AccessorInfo info(v8::Utils::ToLocal(receiver_handle), - v8::Utils::ToLocal(data_handle), - v8::Utils::ToLocal(holder_handle)); + CustomArguments args(interceptor->data(), receiver, this); + v8::AccessorInfo info(args.end()); v8::Handle<v8::Value> result; { // Leaving JavaScript. |