Skip to content

fix maximum object size semantics #18728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2014
Merged

fix maximum object size semantics #18728

merged 1 commit into from
Nov 20, 2014

Conversation

thestinger
Copy link
Contributor

This fixes the gap in the language definition causing #18726 by defining
a clear bound on the maximum size for libraries to enforce.

Closes #18069

@thestinger thestinger changed the title clarify maximum object size semantics in the manual fix maximum object size semantics Nov 7, 2014
@nikomatsakis
Copy link
Contributor

On IRC, @arielb1 pointed out that the bound for 64-bit systems is wrong, because LLVM measures in bits not bytes in some places. @cmr can you remove the r+ please?

@nikomatsakis
Copy link
Contributor

(It seems I can't do it due to github permissions...)

@arielb1
Copy link
Contributor

arielb1 commented Nov 7, 2014

@thestinger

max_obj_size is exclusive, so you can't create an object of size (1<<31) even without your patch. We may want to improve the name/comments through.

@thestinger
Copy link
Contributor Author

@arielb1: I think max_obj_size is a good name, but it's not actually what it does right now.

@huonw
Copy link
Member

huonw commented Nov 7, 2014

@nikomatsakis, I believe bors will notice an r- comment after an r+, to stop the merge.

@nikomatsakis
Copy link
Contributor

Yeah I tried that later :)

Niko

-------- Original message --------
From: Huon Wilson notifications@github.com
Date:11/07/2014 16:42 (GMT-05:00)
To: rust-lang/rust rust@noreply.github.com
Cc: Niko Matsakis niko@alum.mit.edu
Subject: Re: [rust] fix maximum object size semantics (#18728)

@nikomatsakis, I believe bors will notice an r- comment after an r+, to stop the merge.


Reply to this email directly or view it on GitHub.

// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a line, failing tidy

platform's pointer type. It can represent every memory address in the process.

The `int` type is a signed integer type with the same number of bits as the
platform's pointer type. The theoretical upper object on object size and array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Upper object" is still here and still makes no sense.

@huonw
Copy link
Member

huonw commented Nov 8, 2014

(Cycling to stop bors.)

@huonw huonw closed this Nov 8, 2014
@huonw huonw reopened this Nov 8, 2014
@huonw
Copy link
Member

huonw commented Nov 8, 2014

(I think it may be a good idea to ask for a re-review next time. :) )

@nikomatsakis nikomatsakis self-assigned this Nov 8, 2014
// represent object size in bits. It is currently conservatively bounded to 1 << 47 as that is
// enough to cover the current usable address space on 64-bit ARMv8 and x86_64.
pub fn obj_size_bound(&self) -> u64 {
match self.sess().target.target.target_word_size[] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you either add Fixes #18069 or keep the FIXME #18069 but change the text to "Investigate LLVM support for huge objects more deeply"? I doubt we've done the investigation, but it also seems like one of those open-ended issues that can never truly be closed (even if we DID exhaustively read each line of LLVM, it will keep being edited), so I'm not sure it's worth keeping around. Matching clang's limits might help give us confidence, of course we can't do that programmatically.

@nikomatsakis
Copy link
Contributor

OK, modulo nits this seems good to me. @thestinger I think you mentioned that clang is much more conservative here? What limits do they use? Is there a good reason not to just match them?

@nikomatsakis
Copy link
Contributor

Ping @arielb1, I'd like your opinion on the revised commit as well. You mentioned in #18069 a certain amount of trepidation regarding LLVM internals. (See my comments here though; in the absence of documented LLVM limits, at some point we have to trust them.)

@nikomatsakis
Copy link
Contributor

On Fri, Nov 07, 2014 at 12:47:45PM -0800, Daniel Micay wrote:

@arielb1: I think max_obj_size is a good name, but it's not actually what it does right now.

I missed this before: can you elaborate on what you see as the
distinction between the "max obj size" and the "obj size bound"? They
sound like synonyms to me. Are you refererring to the fact that one
could use malloc to create a (dynamically allocated) object?

@arielb1
Copy link
Contributor

arielb1 commented Nov 8, 2014

@nikomatsakis

obj_size_bound is a better name as it is an exclusive (rather than inclusive) bound.

LLVM has serious problems with objects of size 1<<61 (as it likes to work with u64 sizes in bits). We're setting the bound to 1<<47, as you can't have objects larger than that on x86-64/ARMv8 anyway.

The new test should use 1<<47 instead of 1<<61, of course.

@nikomatsakis
Copy link
Contributor

@arielb1 weren't there some compile-fail tests that would need to be updated to account for the fact that this patch permits larger objects than before?

@nikomatsakis
Copy link
Contributor

@arielb1 regarding exclusivity, that makes sense. I tend not to make assumptions about whether words like "max" or "bound" are inclusive or exclusive but I agree that bound is less ambiguous.

@nikomatsakis
Copy link
Contributor

@thestinger any plans to submit an updated version of this PR? seems like it's just some naming / english nits blocking it.

This fixes the gap in the language definition causing #18726 by defining
a clear bound on the maximum size for libraries to enforce.

Closes #18069
bors added a commit that referenced this pull request Nov 19, 2014
This fixes the gap in the language definition causing #18726 by defining
a clear bound on the maximum size for libraries to enforce.

Closes #18069
@bors bors closed this Nov 20, 2014
@bors bors merged commit 210e059 into rust-lang:master Nov 20, 2014
@thestinger thestinger deleted the int branch January 28, 2015 03:09
lnicola pushed a commit to lnicola/rust that referenced this pull request Dec 23, 2024
internal: Split `serde` derive feature into `serde_derive` usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate LLVM support for huge objects
6 participants