| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 int offset, | 84 int offset, |
| 85 int* object_offset) { | 85 int* object_offset) { |
| 86 if (name->Equals(property_name)) { | 86 if (name->Equals(property_name)) { |
| 87 *object_offset = offset; | 87 *object_offset = offset; |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| 90 return false; | 90 return false; |
| 91 } | 91 } |
| 92 | 92 |
| 93 | 93 |
| 94 bool Accessors::IsJSObjectFieldAccessor( | 94 bool Accessors::IsJSObjectFieldAccessor(Handle<HeapType> type, |
| 95 Handle<Map> map, Handle<String> name, | 95 Handle<String> name, |
| 96 int* object_offset) { | 96 int* object_offset) { |
| 97 Isolate* isolate = map->GetIsolate(); | 97 Isolate* isolate = name->GetIsolate(); |
| 98 |
| 99 if (type->Is(HeapType::String())) { |
| 100 return CheckForName(name, isolate->heap()->length_string(), |
| 101 String::kLengthOffset, object_offset); |
| 102 } |
| 103 |
| 104 if (!type->IsClass()) return false; |
| 105 Handle<Map> map = type->AsClass(); |
| 106 |
| 98 switch (map->instance_type()) { | 107 switch (map->instance_type()) { |
| 99 case JS_ARRAY_TYPE: | 108 case JS_ARRAY_TYPE: |
| 100 return | 109 return |
| 101 CheckForName(name, isolate->heap()->length_string(), | 110 CheckForName(name, isolate->heap()->length_string(), |
| 102 JSArray::kLengthOffset, object_offset); | 111 JSArray::kLengthOffset, object_offset); |
| 103 case JS_TYPED_ARRAY_TYPE: | 112 case JS_TYPED_ARRAY_TYPE: |
| 104 return | 113 return |
| 105 CheckForName(name, isolate->heap()->length_string(), | 114 CheckForName(name, isolate->heap()->length_string(), |
| 106 JSTypedArray::kLengthOffset, object_offset) || | 115 JSTypedArray::kLengthOffset, object_offset) || |
| 107 CheckForName(name, isolate->heap()->byte_length_string(), | 116 CheckForName(name, isolate->heap()->byte_length_string(), |
| 108 JSTypedArray::kByteLengthOffset, object_offset) || | 117 JSTypedArray::kByteLengthOffset, object_offset) || |
| 109 CheckForName(name, isolate->heap()->byte_offset_string(), | 118 CheckForName(name, isolate->heap()->byte_offset_string(), |
| 110 JSTypedArray::kByteOffsetOffset, object_offset) || | 119 JSTypedArray::kByteOffsetOffset, object_offset) || |
| 111 CheckForName(name, isolate->heap()->buffer_string(), | 120 CheckForName(name, isolate->heap()->buffer_string(), |
| 112 JSTypedArray::kBufferOffset, object_offset); | 121 JSTypedArray::kBufferOffset, object_offset); |
| 113 case JS_ARRAY_BUFFER_TYPE: | 122 case JS_ARRAY_BUFFER_TYPE: |
| 114 return | 123 return |
| 115 CheckForName(name, isolate->heap()->byte_length_string(), | 124 CheckForName(name, isolate->heap()->byte_length_string(), |
| 116 JSArrayBuffer::kByteLengthOffset, object_offset); | 125 JSArrayBuffer::kByteLengthOffset, object_offset); |
| 117 case JS_DATA_VIEW_TYPE: | 126 case JS_DATA_VIEW_TYPE: |
| 118 return | 127 return |
| 119 CheckForName(name, isolate->heap()->byte_length_string(), | 128 CheckForName(name, isolate->heap()->byte_length_string(), |
| 120 JSDataView::kByteLengthOffset, object_offset) || | 129 JSDataView::kByteLengthOffset, object_offset) || |
| 121 CheckForName(name, isolate->heap()->byte_offset_string(), | 130 CheckForName(name, isolate->heap()->byte_offset_string(), |
| 122 JSDataView::kByteOffsetOffset, object_offset) || | 131 JSDataView::kByteOffsetOffset, object_offset) || |
| 123 CheckForName(name, isolate->heap()->buffer_string(), | 132 CheckForName(name, isolate->heap()->buffer_string(), |
| 124 JSDataView::kBufferOffset, object_offset); | 133 JSDataView::kBufferOffset, object_offset); |
| 125 default: { | 134 default: |
| 126 if (map->instance_type() < FIRST_NONSTRING_TYPE) { | |
| 127 return | |
| 128 CheckForName(name, isolate->heap()->length_string(), | |
| 129 String::kLengthOffset, object_offset); | |
| 130 } | |
| 131 return false; | 135 return false; |
| 132 } | |
| 133 } | 136 } |
| 134 } | 137 } |
| 135 | 138 |
| 136 | 139 |
| 137 // | 140 // |
| 138 // Accessors::ArrayLength | 141 // Accessors::ArrayLength |
| 139 // | 142 // |
| 140 | 143 |
| 141 | 144 |
| 142 MaybeObject* Accessors::ArrayGetLength(Isolate* isolate, | 145 MaybeObject* Accessors::ArrayGetLength(Isolate* isolate, |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 Object); | 702 Object); |
| 700 } | 703 } |
| 701 | 704 |
| 702 | 705 |
| 703 static MaybeObject* ConstructArgumentsObjectForInlinedFunction( | 706 static MaybeObject* ConstructArgumentsObjectForInlinedFunction( |
| 704 JavaScriptFrame* frame, | 707 JavaScriptFrame* frame, |
| 705 Handle<JSFunction> inlined_function, | 708 Handle<JSFunction> inlined_function, |
| 706 int inlined_frame_index) { | 709 int inlined_frame_index) { |
| 707 Isolate* isolate = inlined_function->GetIsolate(); | 710 Isolate* isolate = inlined_function->GetIsolate(); |
| 708 Factory* factory = isolate->factory(); | 711 Factory* factory = isolate->factory(); |
| 709 Vector<SlotRef> args_slots = | 712 SlotRefValueBuilder slot_refs( |
| 710 SlotRef::ComputeSlotMappingForArguments( | 713 frame, |
| 711 frame, | 714 inlined_frame_index, |
| 712 inlined_frame_index, | 715 inlined_function->shared()->formal_parameter_count()); |
| 713 inlined_function->shared()->formal_parameter_count()); | 716 |
| 714 int args_count = args_slots.length(); | 717 int args_count = slot_refs.args_length(); |
| 715 Handle<JSObject> arguments = | 718 Handle<JSObject> arguments = |
| 716 factory->NewArgumentsObject(inlined_function, args_count); | 719 factory->NewArgumentsObject(inlined_function, args_count); |
| 717 Handle<FixedArray> array = factory->NewFixedArray(args_count); | 720 Handle<FixedArray> array = factory->NewFixedArray(args_count); |
| 721 slot_refs.Prepare(isolate); |
| 718 for (int i = 0; i < args_count; ++i) { | 722 for (int i = 0; i < args_count; ++i) { |
| 719 Handle<Object> value = args_slots[i].GetValue(isolate); | 723 Handle<Object> value = slot_refs.GetNext(isolate, 0); |
| 720 array->set(i, *value); | 724 array->set(i, *value); |
| 721 } | 725 } |
| 726 slot_refs.Finish(isolate); |
| 722 arguments->set_elements(*array); | 727 arguments->set_elements(*array); |
| 723 args_slots.Dispose(); | |
| 724 | 728 |
| 725 // Return the freshly allocated arguments object. | 729 // Return the freshly allocated arguments object. |
| 726 return *arguments; | 730 return *arguments; |
| 727 } | 731 } |
| 728 | 732 |
| 729 | 733 |
| 730 MaybeObject* Accessors::FunctionGetArguments(Isolate* isolate, | 734 MaybeObject* Accessors::FunctionGetArguments(Isolate* isolate, |
| 731 Object* object, | 735 Object* object, |
| 732 void*) { | 736 void*) { |
| 733 HandleScope scope(isolate); | 737 HandleScope scope(isolate); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 info->set_data(Smi::FromInt(index)); | 973 info->set_data(Smi::FromInt(index)); |
| 970 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); | 974 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); |
| 971 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); | 975 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); |
| 972 info->set_getter(*getter); | 976 info->set_getter(*getter); |
| 973 if (!(attributes & ReadOnly)) info->set_setter(*setter); | 977 if (!(attributes & ReadOnly)) info->set_setter(*setter); |
| 974 return info; | 978 return info; |
| 975 } | 979 } |
| 976 | 980 |
| 977 | 981 |
| 978 } } // namespace v8::internal | 982 } } // namespace v8::internal |
| OLD | NEW |