Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: src/api.cc

Issue 8139027: Version 3.6.5 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/SConscript ('k') | src/arm/assembler-arm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 heap_stats.memory_allocator_capacity = &memory_allocator_capacity; 178 heap_stats.memory_allocator_capacity = &memory_allocator_capacity;
179 int objects_per_type[LAST_TYPE + 1] = {0}; 179 int objects_per_type[LAST_TYPE + 1] = {0};
180 heap_stats.objects_per_type = objects_per_type; 180 heap_stats.objects_per_type = objects_per_type;
181 int size_per_type[LAST_TYPE + 1] = {0}; 181 int size_per_type[LAST_TYPE + 1] = {0};
182 heap_stats.size_per_type = size_per_type; 182 heap_stats.size_per_type = size_per_type;
183 int os_error; 183 int os_error;
184 heap_stats.os_error = &os_error; 184 heap_stats.os_error = &os_error;
185 int end_marker; 185 int end_marker;
186 heap_stats.end_marker = &end_marker; 186 heap_stats.end_marker = &end_marker;
187 i::Isolate* isolate = i::Isolate::Current(); 187 i::Isolate* isolate = i::Isolate::Current();
188 isolate->heap()->RecordStats(&heap_stats, take_snapshot); 188 // BUG(1718):
189 // Don't use the take_snapshot since we don't support HeapIterator here
190 // without doing a special GC.
191 isolate->heap()->RecordStats(&heap_stats, false);
189 i::V8::SetFatalError(); 192 i::V8::SetFatalError();
190 FatalErrorCallback callback = GetFatalErrorHandler(); 193 FatalErrorCallback callback = GetFatalErrorHandler();
191 { 194 {
192 LEAVE_V8(isolate); 195 LEAVE_V8(isolate);
193 callback(location, "Allocation failed - process out of memory"); 196 callback(location, "Allocation failed - process out of memory");
194 } 197 }
195 // If the callback returns, we stop execution. 198 // If the callback returns, we stop execution.
196 UNREACHABLE(); 199 UNREACHABLE();
197 } 200 }
198 201
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 497
495 void RegisterExtension(Extension* that) { 498 void RegisterExtension(Extension* that) {
496 RegisteredExtension* extension = new RegisteredExtension(that); 499 RegisteredExtension* extension = new RegisteredExtension(that);
497 RegisteredExtension::Register(extension); 500 RegisteredExtension::Register(extension);
498 } 501 }
499 502
500 503
501 Extension::Extension(const char* name, 504 Extension::Extension(const char* name,
502 const char* source, 505 const char* source,
503 int dep_count, 506 int dep_count,
504 const char** deps) 507 const char** deps,
508 int source_length)
505 : name_(name), 509 : name_(name),
506 source_(source), 510 source_length_(source_length >= 0 ?
511 source_length : (source ? strlen(source) : 0)),
512 source_(source, source_length_),
507 dep_count_(dep_count), 513 dep_count_(dep_count),
508 deps_(deps), 514 deps_(deps),
509 auto_enable_(false) { } 515 auto_enable_(false) { }
510 516
511 517
512 v8::Handle<Primitive> Undefined() { 518 v8::Handle<Primitive> Undefined() {
513 i::Isolate* isolate = i::Isolate::Current(); 519 i::Isolate* isolate = i::Isolate::Current();
514 if (!EnsureInitializedForIsolate(isolate, "v8::Undefined()")) { 520 if (!EnsureInitializedForIsolate(isolate, "v8::Undefined()")) {
515 return v8::Handle<v8::Primitive>(); 521 return v8::Handle<v8::Primitive>();
516 } 522 }
(...skipping 2680 matching lines...) Expand 10 before | Expand all | Expand 10 after
3197 } 3203 }
3198 3204
3199 3205
3200 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, 3206 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key,
3201 v8::Handle<v8::Value> value) { 3207 v8::Handle<v8::Value> value) {
3202 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3208 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3203 ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false); 3209 ON_BAILOUT(isolate, "v8::Object::SetHiddenValue()", return false);
3204 ENTER_V8(isolate); 3210 ENTER_V8(isolate);
3205 i::HandleScope scope(isolate); 3211 i::HandleScope scope(isolate);
3206 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3212 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3207 i::Handle<i::Object> hidden_props(i::GetHiddenProperties( 3213 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3208 self,
3209 i::JSObject::ALLOW_CREATION));
3210 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3211 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3214 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3212 EXCEPTION_PREAMBLE(isolate); 3215 i::Handle<i::Object> result = i::SetHiddenProperty(self, key_obj, value_obj);
3213 i::Handle<i::Object> obj = i::SetProperty( 3216 return *result == *self;
3214 hidden_props,
3215 key_obj,
3216 value_obj,
3217 static_cast<PropertyAttributes>(None),
3218 i::kNonStrictMode);
3219 has_pending_exception = obj.is_null();
3220 EXCEPTION_BAILOUT_CHECK(isolate, false);
3221 return true;
3222 } 3217 }
3223 3218
3224 3219
3225 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { 3220 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) {
3226 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3221 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3227 ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()", 3222 ON_BAILOUT(isolate, "v8::Object::GetHiddenValue()",
3228 return Local<v8::Value>()); 3223 return Local<v8::Value>());
3229 ENTER_V8(isolate); 3224 ENTER_V8(isolate);
3230 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3225 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3231 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(
3232 self,
3233 i::JSObject::OMIT_CREATION));
3234 if (hidden_props->IsUndefined()) {
3235 return v8::Local<v8::Value>();
3236 }
3237 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 3226 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3238 EXCEPTION_PREAMBLE(isolate); 3227 i::Handle<i::Object> result(self->GetHiddenProperty(*key_obj));
3239 i::Handle<i::Object> result = i::GetProperty(hidden_props, key_obj); 3228 if (result->IsUndefined()) return v8::Local<v8::Value>();
3240 has_pending_exception = result.is_null();
3241 EXCEPTION_BAILOUT_CHECK(isolate, v8::Local<v8::Value>());
3242 if (result->IsUndefined()) {
3243 return v8::Local<v8::Value>();
3244 }
3245 return Utils::ToLocal(result); 3229 return Utils::ToLocal(result);
3246 } 3230 }
3247 3231
3248 3232
3249 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) { 3233 bool v8::Object::DeleteHiddenValue(v8::Handle<v8::String> key) {
3250 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3234 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3251 ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false); 3235 ON_BAILOUT(isolate, "v8::DeleteHiddenValue()", return false);
3252 ENTER_V8(isolate); 3236 ENTER_V8(isolate);
3253 i::HandleScope scope(isolate); 3237 i::HandleScope scope(isolate);
3254 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3238 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3255 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(
3256 self,
3257 i::JSObject::OMIT_CREATION));
3258 if (hidden_props->IsUndefined()) {
3259 return true;
3260 }
3261 i::Handle<i::JSObject> js_obj(i::JSObject::cast(*hidden_props));
3262 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 3239 i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
3263 return i::DeleteProperty(js_obj, key_obj)->IsTrue(); 3240 self->DeleteHiddenProperty(*key_obj);
3241 return true;
3264 } 3242 }
3265 3243
3266 3244
3267 namespace { 3245 namespace {
3268 3246
3269 static i::ElementsKind GetElementsKindFromExternalArrayType( 3247 static i::ElementsKind GetElementsKindFromExternalArrayType(
3270 ExternalArrayType array_type) { 3248 ExternalArrayType array_type) {
3271 switch (array_type) { 3249 switch (array_type) {
3272 case kExternalByteArray: 3250 case kExternalByteArray:
3273 return i::EXTERNAL_BYTE_ELEMENTS; 3251 return i::EXTERNAL_BYTE_ELEMENTS;
(...skipping 29 matching lines...) Expand all
3303 3281
3304 3282
3305 void PrepareExternalArrayElements(i::Handle<i::JSObject> object, 3283 void PrepareExternalArrayElements(i::Handle<i::JSObject> object,
3306 void* data, 3284 void* data,
3307 ExternalArrayType array_type, 3285 ExternalArrayType array_type,
3308 int length) { 3286 int length) {
3309 i::Isolate* isolate = object->GetIsolate(); 3287 i::Isolate* isolate = object->GetIsolate();
3310 i::Handle<i::ExternalArray> array = 3288 i::Handle<i::ExternalArray> array =
3311 isolate->factory()->NewExternalArray(length, array_type, data); 3289 isolate->factory()->NewExternalArray(length, array_type, data);
3312 3290
3313 // If the object already has external elements, create a new, unique 3291 i::Handle<i::Map> external_array_map =
3314 // map if the element type is now changing, because assumptions about 3292 isolate->factory()->GetElementsTransitionMap(
3315 // generated code based on the receiver's map will be invalid. 3293 object,
3316 i::Handle<i::HeapObject> elements(object->elements()); 3294 GetElementsKindFromExternalArrayType(array_type));
3317 bool cant_reuse_map = 3295
3318 elements->map()->IsUndefined() || 3296 object->set_map(*external_array_map);
3319 !elements->map()->has_external_array_elements() ||
3320 elements->map() != isolate->heap()->MapForExternalArrayType(array_type);
3321 if (cant_reuse_map) {
3322 i::Handle<i::Map> external_array_map =
3323 isolate->factory()->GetElementsTransitionMap(
3324 i::Handle<i::Map>(object->map()),
3325 GetElementsKindFromExternalArrayType(array_type),
3326 object->HasFastProperties());
3327 object->set_map(*external_array_map);
3328 }
3329 object->set_elements(*array); 3297 object->set_elements(*array);
3330 } 3298 }
3331 3299
3332 } // namespace 3300 } // namespace
3333 3301
3334 3302
3335 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) { 3303 void v8::Object::SetIndexedPropertiesToPixelData(uint8_t* data, int length) {
3336 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3304 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3337 ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return); 3305 ON_BAILOUT(isolate, "v8::SetElementsToPixelData()", return);
3338 ENTER_V8(isolate); 3306 ENTER_V8(isolate);
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
3792 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternalAscii()")) { 3760 if (IsDeadCheck(str->GetIsolate(), "v8::String::IsExternalAscii()")) {
3793 return false; 3761 return false;
3794 } 3762 }
3795 return i::StringShape(*str).IsExternalAscii(); 3763 return i::StringShape(*str).IsExternalAscii();
3796 } 3764 }
3797 3765
3798 3766
3799 void v8::String::VerifyExternalStringResource( 3767 void v8::String::VerifyExternalStringResource(
3800 v8::String::ExternalStringResource* value) const { 3768 v8::String::ExternalStringResource* value) const {
3801 i::Handle<i::String> str = Utils::OpenHandle(this); 3769 i::Handle<i::String> str = Utils::OpenHandle(this);
3802 v8::String::ExternalStringResource* expected; 3770 const v8::String::ExternalStringResource* expected;
3803 if (i::StringShape(*str).IsExternalTwoByte()) { 3771 if (i::StringShape(*str).IsExternalTwoByte()) {
3804 void* resource = i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); 3772 const void* resource =
3805 expected = reinterpret_cast<ExternalStringResource*>(resource); 3773 i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
3774 expected = reinterpret_cast<const ExternalStringResource*>(resource);
3806 } else { 3775 } else {
3807 expected = NULL; 3776 expected = NULL;
3808 } 3777 }
3809 CHECK_EQ(expected, value); 3778 CHECK_EQ(expected, value);
3810 } 3779 }
3811 3780
3812 3781
3813 v8::String::ExternalAsciiStringResource* 3782 const v8::String::ExternalAsciiStringResource*
3814 v8::String::GetExternalAsciiStringResource() const { 3783 v8::String::GetExternalAsciiStringResource() const {
3815 i::Handle<i::String> str = Utils::OpenHandle(this); 3784 i::Handle<i::String> str = Utils::OpenHandle(this);
3816 if (IsDeadCheck(str->GetIsolate(), 3785 if (IsDeadCheck(str->GetIsolate(),
3817 "v8::String::GetExternalAsciiStringResource()")) { 3786 "v8::String::GetExternalAsciiStringResource()")) {
3818 return NULL; 3787 return NULL;
3819 } 3788 }
3820 if (i::StringShape(*str).IsExternalAscii()) { 3789 if (i::StringShape(*str).IsExternalAscii()) {
3821 void* resource = i::Handle<i::ExternalAsciiString>::cast(str)->resource(); 3790 const void* resource =
3822 return reinterpret_cast<ExternalAsciiStringResource*>(resource); 3791 i::Handle<i::ExternalAsciiString>::cast(str)->resource();
3792 return reinterpret_cast<const ExternalAsciiStringResource*>(resource);
3823 } else { 3793 } else {
3824 return NULL; 3794 return NULL;
3825 } 3795 }
3826 } 3796 }
3827 3797
3828 3798
3829 double Number::Value() const { 3799 double Number::Value() const {
3830 if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Value()")) return 0; 3800 if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Value()")) return 0;
3831 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3801 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3832 return obj->Number(); 3802 return obj->Number();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
4002 // Returning true tells the caller that it need not 3972 // Returning true tells the caller that it need not
4003 // continue to call IdleNotification. 3973 // continue to call IdleNotification.
4004 if (!i::Isolate::Current()->IsInitialized()) return true; 3974 if (!i::Isolate::Current()->IsInitialized()) return true;
4005 return i::V8::IdleNotification(); 3975 return i::V8::IdleNotification();
4006 } 3976 }
4007 3977
4008 3978
4009 void v8::V8::LowMemoryNotification() { 3979 void v8::V8::LowMemoryNotification() {
4010 i::Isolate* isolate = i::Isolate::Current(); 3980 i::Isolate* isolate = i::Isolate::Current();
4011 if (!isolate->IsInitialized()) return; 3981 if (!isolate->IsInitialized()) return;
4012 isolate->heap()->CollectAllGarbage(true); 3982 isolate->heap()->CollectAllAvailableGarbage();
4013 } 3983 }
4014 3984
4015 3985
4016 int v8::V8::ContextDisposedNotification() { 3986 int v8::V8::ContextDisposedNotification() {
4017 i::Isolate* isolate = i::Isolate::Current(); 3987 i::Isolate* isolate = i::Isolate::Current();
4018 if (!isolate->IsInitialized()) return 0; 3988 if (!isolate->IsInitialized()) return 0;
4019 return isolate->heap()->NotifyContextDisposed(); 3989 return isolate->heap()->NotifyContextDisposed();
4020 } 3990 }
4021 3991
4022 3992
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after
5473 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); 5443 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>());
5474 return scope.Close(result); 5444 return scope.Close(result);
5475 } 5445 }
5476 5446
5477 5447
5478 bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) { 5448 bool Debug::EnableAgent(const char* name, int port, bool wait_for_connection) {
5479 return i::Isolate::Current()->debugger()->StartAgent(name, port, 5449 return i::Isolate::Current()->debugger()->StartAgent(name, port,
5480 wait_for_connection); 5450 wait_for_connection);
5481 } 5451 }
5482 5452
5453
5454 void Debug::DisableAgent() {
5455 return i::Isolate::Current()->debugger()->StopAgent();
5456 }
5457
5458
5483 void Debug::ProcessDebugMessages() { 5459 void Debug::ProcessDebugMessages() {
5484 i::Execution::ProcessDebugMesssages(true); 5460 i::Execution::ProcessDebugMesssages(true);
5485 } 5461 }
5486 5462
5487 Local<Context> Debug::GetDebugContext() { 5463 Local<Context> Debug::GetDebugContext() {
5488 i::Isolate* isolate = i::Isolate::Current(); 5464 i::Isolate* isolate = i::Isolate::Current();
5489 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()"); 5465 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()");
5490 ENTER_V8(isolate); 5466 ENTER_V8(isolate);
5491 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext()); 5467 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext());
5492 } 5468 }
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
5797 } 5773 }
5798 5774
5799 5775
5800 const HeapGraphNode* HeapGraphNode::GetDominatorNode() const { 5776 const HeapGraphNode* HeapGraphNode::GetDominatorNode() const {
5801 i::Isolate* isolate = i::Isolate::Current(); 5777 i::Isolate* isolate = i::Isolate::Current();
5802 IsDeadCheck(isolate, "v8::HeapSnapshot::GetDominatorNode"); 5778 IsDeadCheck(isolate, "v8::HeapSnapshot::GetDominatorNode");
5803 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->dominator()); 5779 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->dominator());
5804 } 5780 }
5805 5781
5806 5782
5783 v8::Handle<v8::Value> HeapGraphNode::GetHeapValue() const {
5784 i::Isolate* isolate = i::Isolate::Current();
5785 IsDeadCheck(isolate, "v8::HeapGraphNode::GetHeapValue");
5786 i::Handle<i::HeapObject> object = ToInternal(this)->GetHeapObject();
5787 return v8::Handle<Value>(!object.is_null() ?
5788 ToApi<Value>(object) : ToApi<Value>(
5789 isolate->factory()->undefined_value()));
5790 }
5791
5792
5807 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { 5793 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) {
5808 return const_cast<i::HeapSnapshot*>( 5794 return const_cast<i::HeapSnapshot*>(
5809 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); 5795 reinterpret_cast<const i::HeapSnapshot*>(snapshot));
5810 } 5796 }
5811 5797
5812 5798
5813 void HeapSnapshot::Delete() { 5799 void HeapSnapshot::Delete() {
5814 i::Isolate* isolate = i::Isolate::Current(); 5800 i::Isolate* isolate = i::Isolate::Current();
5815 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete"); 5801 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete");
5816 if (i::HeapProfiler::GetSnapshotsCount() > 1) { 5802 if (i::HeapProfiler::GetSnapshotsCount() > 1) {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
6076 6062
6077 6063
6078 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 6064 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
6079 HandleScopeImplementer* scope_implementer = 6065 HandleScopeImplementer* scope_implementer =
6080 reinterpret_cast<HandleScopeImplementer*>(storage); 6066 reinterpret_cast<HandleScopeImplementer*>(storage);
6081 scope_implementer->IterateThis(v); 6067 scope_implementer->IterateThis(v);
6082 return storage + ArchiveSpacePerThread(); 6068 return storage + ArchiveSpacePerThread();
6083 } 6069 }
6084 6070
6085 } } // namespace v8::internal 6071 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/SConscript ('k') | src/arm/assembler-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698