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

Side by Side Diff: src/api.cc

Issue 11212004: Add a faster API for creating v8::Integer objects (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 8 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
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.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 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 5173 matching lines...) Expand 10 before | Expand all | Expand 10 after
5184 } 5184 }
5185 ENTER_V8(isolate); 5185 ENTER_V8(isolate);
5186 i::Handle<i::Object> result = isolate->factory()->NewNumber(value); 5186 i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
5187 return Utils::NumberToLocal(result); 5187 return Utils::NumberToLocal(result);
5188 } 5188 }
5189 5189
5190 5190
5191 Local<Integer> v8::Integer::New(int32_t value) { 5191 Local<Integer> v8::Integer::New(int32_t value) {
5192 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); 5192 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
5193 EnsureInitializedForIsolate(isolate, "v8::Integer::New()"); 5193 EnsureInitializedForIsolate(isolate, "v8::Integer::New()");
5194 return v8::Integer::New(value, reinterpret_cast<Isolate*>(isolate));
5195 }
5196
5197
5198 Local<Integer> Integer::NewFromUnsigned(uint32_t value) {
5199 i::Isolate* isolate = i::Isolate::Current();
5200 EnsureInitializedForIsolate(isolate, "v8::Integer::NewFromUnsigned()");
5201 return Integer::NewFromUnsigned(value, reinterpret_cast<Isolate*>(isolate));
5202 }
5203
5204
5205 Local<Integer> v8::Integer::New(int32_t value, Isolate* isolate) {
5206 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
5207 ASSERT(internal_isolate->IsInitialized());
5194 if (i::Smi::IsValid(value)) { 5208 if (i::Smi::IsValid(value)) {
5195 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value), 5209 return Utils::IntegerToLocal(i::Handle<i::Object>(i::Smi::FromInt(value),
5196 isolate)); 5210 internal_isolate));
5197 } 5211 }
5198 ENTER_V8(isolate); 5212 ENTER_V8(internal_isolate);
5199 i::Handle<i::Object> result = isolate->factory()->NewNumber(value); 5213 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
5200 return Utils::IntegerToLocal(result); 5214 return Utils::IntegerToLocal(result);
5201 } 5215 }
5202 5216
5203 5217
5204 Local<Integer> Integer::NewFromUnsigned(uint32_t value) { 5218 Local<Integer> v8::Integer::NewFromUnsigned(uint32_t value, Isolate* isolate) {
5219 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
5220 ASSERT(internal_isolate->IsInitialized());
5205 bool fits_into_int32_t = (value & (1 << 31)) == 0; 5221 bool fits_into_int32_t = (value & (1 << 31)) == 0;
5206 if (fits_into_int32_t) { 5222 if (fits_into_int32_t) {
5207 return Integer::New(static_cast<int32_t>(value)); 5223 return Integer::New(static_cast<int32_t>(value), isolate);
5208 } 5224 }
5209 i::Isolate* isolate = i::Isolate::Current(); 5225 ENTER_V8(internal_isolate);
5210 ENTER_V8(isolate); 5226 i::Handle<i::Object> result = internal_isolate->factory()->NewNumber(value);
5211 i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
5212 return Utils::IntegerToLocal(result); 5227 return Utils::IntegerToLocal(result);
5213 } 5228 }
5214 5229
5215 5230
5216 void V8::IgnoreOutOfMemoryException() { 5231 void V8::IgnoreOutOfMemoryException() {
5217 EnterIsolateIfNeeded()->set_ignore_out_of_memory(true); 5232 EnterIsolateIfNeeded()->set_ignore_out_of_memory(true);
5218 } 5233 }
5219 5234
5220 5235
5221 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) { 5236 bool V8::AddMessageListener(MessageCallback that, Handle<Value> data) {
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
6590 6605
6591 v->VisitPointers(blocks_.first(), first_block_limit_); 6606 v->VisitPointers(blocks_.first(), first_block_limit_);
6592 6607
6593 for (int i = 1; i < blocks_.length(); i++) { 6608 for (int i = 1; i < blocks_.length(); i++) {
6594 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 6609 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6595 } 6610 }
6596 } 6611 }
6597 6612
6598 6613
6599 } } // namespace v8::internal 6614 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698