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

Side by Side Diff: src/api.cc

Issue 7572018: Minimize malloc heap allocation on process startup. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 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/api.h ('k') | src/debug.cc » ('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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 78
79 #define EXCEPTION_BAILOUT_CHECK(isolate, value) \ 79 #define EXCEPTION_BAILOUT_CHECK(isolate, value) \
80 do { \ 80 do { \
81 i::HandleScopeImplementer* handle_scope_implementer = \ 81 i::HandleScopeImplementer* handle_scope_implementer = \
82 (isolate)->handle_scope_implementer(); \ 82 (isolate)->handle_scope_implementer(); \
83 handle_scope_implementer->DecrementCallDepth(); \ 83 handle_scope_implementer->DecrementCallDepth(); \
84 if (has_pending_exception) { \ 84 if (has_pending_exception) { \
85 if (handle_scope_implementer->CallDepthIsZero() && \ 85 if (handle_scope_implementer->CallDepthIsZero() && \
86 (isolate)->is_out_of_memory()) { \ 86 (isolate)->is_out_of_memory()) { \
87 if (!handle_scope_implementer->ignore_out_of_memory()) \ 87 if (!(isolate)->ignore_out_of_memory()) \
88 i::V8::FatalProcessOutOfMemory(NULL); \ 88 i::V8::FatalProcessOutOfMemory(NULL); \
89 } \ 89 } \
90 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ 90 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \
91 (isolate)->OptionalRescheduleException(call_depth_is_zero); \ 91 (isolate)->OptionalRescheduleException(call_depth_is_zero); \
92 return value; \ 92 return value; \
93 } \ 93 } \
94 } while (false) 94 } while (false)
95 95
96 96
97 #define API_ENTRY_CHECK(isolate, msg) \ 97 #define API_ENTRY_CHECK(isolate, msg) \
(...skipping 4154 matching lines...) Expand 10 before | Expand all | Expand 10 after
4252 } 4252 }
4253 4253
4254 static void* ExternalValueImpl(i::Handle<i::Object> obj) { 4254 static void* ExternalValueImpl(i::Handle<i::Object> obj) {
4255 return reinterpret_cast<void*>(i::Foreign::cast(*obj)->address()); 4255 return reinterpret_cast<void*>(i::Foreign::cast(*obj)->address());
4256 } 4256 }
4257 4257
4258 4258
4259 Local<Value> v8::External::Wrap(void* data) { 4259 Local<Value> v8::External::Wrap(void* data) {
4260 i::Isolate* isolate = i::Isolate::Current(); 4260 i::Isolate* isolate = i::Isolate::Current();
4261 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); 4261 STATIC_ASSERT(sizeof(data) == sizeof(i::Address));
4262 EnsureInitializedForIsolate(isolate, "v8::External::Wrap()");
4262 LOG_API(isolate, "External::Wrap"); 4263 LOG_API(isolate, "External::Wrap");
4263 EnsureInitializedForIsolate(isolate, "v8::External::Wrap()");
4264 ENTER_V8(isolate); 4264 ENTER_V8(isolate);
4265 4265
4266 v8::Local<v8::Value> result = CanBeEncodedAsSmi(data) 4266 v8::Local<v8::Value> result = CanBeEncodedAsSmi(data)
4267 ? Utils::ToLocal(i::Handle<i::Object>(EncodeAsSmi(data))) 4267 ? Utils::ToLocal(i::Handle<i::Object>(EncodeAsSmi(data)))
4268 : v8::Local<v8::Value>(ExternalNewImpl(data)); 4268 : v8::Local<v8::Value>(ExternalNewImpl(data));
4269 4269
4270 ASSERT_EQ(data, Unwrap(result)); 4270 ASSERT_EQ(data, Unwrap(result));
4271 return result; 4271 return result;
4272 } 4272 }
4273 4273
(...skipping 23 matching lines...) Expand all
4297 result = NULL; 4297 result = NULL;
4298 } 4298 }
4299 ASSERT_EQ(result, QuickUnwrap(wrapper)); 4299 ASSERT_EQ(result, QuickUnwrap(wrapper));
4300 return result; 4300 return result;
4301 } 4301 }
4302 4302
4303 4303
4304 Local<External> v8::External::New(void* data) { 4304 Local<External> v8::External::New(void* data) {
4305 STATIC_ASSERT(sizeof(data) == sizeof(i::Address)); 4305 STATIC_ASSERT(sizeof(data) == sizeof(i::Address));
4306 i::Isolate* isolate = i::Isolate::Current(); 4306 i::Isolate* isolate = i::Isolate::Current();
4307 EnsureInitializedForIsolate(isolate, "v8::External::New()");
4307 LOG_API(isolate, "External::New"); 4308 LOG_API(isolate, "External::New");
4308 EnsureInitializedForIsolate(isolate, "v8::External::New()");
4309 ENTER_V8(isolate); 4309 ENTER_V8(isolate);
4310 return ExternalNewImpl(data); 4310 return ExternalNewImpl(data);
4311 } 4311 }
4312 4312
4313 4313
4314 void* External::Value() const { 4314 void* External::Value() const {
4315 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Value()")) return 0; 4315 if (IsDeadCheck(i::Isolate::Current(), "v8::External::Value()")) return 0;
4316 i::Handle<i::Object> obj = Utils::OpenHandle(this); 4316 i::Handle<i::Object> obj = Utils::OpenHandle(this);
4317 return ExternalValueImpl(obj); 4317 return ExternalValueImpl(obj);
4318 } 4318 }
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
4790 return Integer::New(static_cast<int32_t>(value)); 4790 return Integer::New(static_cast<int32_t>(value));
4791 } 4791 }
4792 i::Isolate* isolate = i::Isolate::Current(); 4792 i::Isolate* isolate = i::Isolate::Current();
4793 ENTER_V8(isolate); 4793 ENTER_V8(isolate);
4794 i::Handle<i::Object> result = isolate->factory()->NewNumber(value); 4794 i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
4795 return Utils::IntegerToLocal(result); 4795 return Utils::IntegerToLocal(result);
4796 } 4796 }
4797 4797
4798 4798
4799 void V8::IgnoreOutOfMemoryException() { 4799 void V8::IgnoreOutOfMemoryException() {
4800 EnterIsolateIfNeeded()->handle_scope_implementer()->set_ignore_out_of_memory( 4800 EnterIsolateIfNeeded()->set_ignore_out_of_memory(true);
4801 true);
4802 } 4801 }
4803 4802
4804 4803
4805 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { 4804 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
4806 i::Isolate* isolate = i::Isolate::Current(); 4805 i::Isolate* isolate = i::Isolate::Current();
4807 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()"); 4806 EnsureInitializedForIsolate(isolate, "v8::V8::AddMessageListener()");
4808 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false); 4807 ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false);
4809 ENTER_V8(isolate); 4808 ENTER_V8(isolate);
4810 i::HandleScope scope(isolate); 4809 i::HandleScope scope(isolate);
4811 NeanderArray listeners(isolate->factory()->message_listeners()); 4810 NeanderArray listeners(isolate->factory()->message_listeners());
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
6037 6036
6038 6037
6039 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 6038 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
6040 HandleScopeImplementer* scope_implementer = 6039 HandleScopeImplementer* scope_implementer =
6041 reinterpret_cast<HandleScopeImplementer*>(storage); 6040 reinterpret_cast<HandleScopeImplementer*>(storage);
6042 scope_implementer->IterateThis(v); 6041 scope_implementer->IterateThis(v);
6043 return storage + ArchiveSpacePerThread(); 6042 return storage + ArchiveSpacePerThread();
6044 } 6043 }
6045 6044
6046 } } // namespace v8::internal 6045 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698