OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 3942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3953 if (IsDeadCheck("v8::RegExp::GetFlags()")) return v8::RegExp::kNone; | 3953 if (IsDeadCheck("v8::RegExp::GetFlags()")) return v8::RegExp::kNone; |
3954 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); | 3954 i::Handle<i::JSRegExp> obj = Utils::OpenHandle(this); |
3955 return static_cast<RegExp::Flags>(obj->GetFlags().value()); | 3955 return static_cast<RegExp::Flags>(obj->GetFlags().value()); |
3956 } | 3956 } |
3957 | 3957 |
3958 | 3958 |
3959 Local<v8::Array> v8::Array::New(int length) { | 3959 Local<v8::Array> v8::Array::New(int length) { |
3960 EnsureInitialized("v8::Array::New()"); | 3960 EnsureInitialized("v8::Array::New()"); |
3961 LOG_API("Array::New"); | 3961 LOG_API("Array::New"); |
3962 ENTER_V8; | 3962 ENTER_V8; |
3963 i::Handle<i::JSArray> obj = i::Factory::NewJSArray(length); | 3963 int real_length = length > 0 ? length : 0; |
| 3964 i::Handle<i::JSArray> obj = i::Factory::NewJSArray(real_length); |
| 3965 obj->set_length(*i::Factory::NewNumberFromInt(real_length)); |
3964 return Utils::ToLocal(obj); | 3966 return Utils::ToLocal(obj); |
3965 } | 3967 } |
3966 | 3968 |
3967 | 3969 |
3968 uint32_t v8::Array::Length() const { | 3970 uint32_t v8::Array::Length() const { |
3969 if (IsDeadCheck("v8::Array::Length()")) return 0; | 3971 if (IsDeadCheck("v8::Array::Length()")) return 0; |
3970 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); | 3972 i::Handle<i::JSArray> obj = Utils::OpenHandle(this); |
3971 i::Object* length = obj->length(); | 3973 i::Object* length = obj->length(); |
3972 if (length->IsSmi()) { | 3974 if (length->IsSmi()) { |
3973 return i::Smi::cast(length)->value(); | 3975 return i::Smi::cast(length)->value(); |
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5235 | 5237 |
5236 | 5238 |
5237 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 5239 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
5238 HandleScopeImplementer* thread_local = | 5240 HandleScopeImplementer* thread_local = |
5239 reinterpret_cast<HandleScopeImplementer*>(storage); | 5241 reinterpret_cast<HandleScopeImplementer*>(storage); |
5240 thread_local->IterateThis(v); | 5242 thread_local->IterateThis(v); |
5241 return storage + ArchiveSpacePerThread(); | 5243 return storage + ArchiveSpacePerThread(); |
5242 } | 5244 } |
5243 | 5245 |
5244 } } // namespace v8::internal | 5246 } } // namespace v8::internal |
OLD | NEW |